Thread: Tables in ePub
View Single Post
Old 12-02-2021, 10:35 PM   #6
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by Artie View Post
Hello, I kindly ask if it is possible to have tables in an ePub file.
Yes. See this topic from a few months ago:

"Formatting tables best practices"

Quote:
Originally Posted by Artie View Post
I am only capable to handle the document in Google Drive. It exports .EPUB, but I cannot control the table. Sometimes they act weirdly.
What do you mean it "acts weirdly"?

Probably because Google Docs creates absolutely atrocious HTML. But there's no reason you can't open the EPUB up in Sigil (or Calibre's Editor) and clean up the crud.

HTML Tables pretty much just boil down to these simple parts:
  • <table>
    • This is the table
  • <tr>
    • Use this for every new row.
  • <th>
    • This is your headings.
  • <td>
    • This is your data.

Code:
<table>
	<tr>
		<th>First</th>
		<th>Last</th>
	</tr>
	<tr>
		<td>John</td>
		<td>Smith</td>
	</tr>
	<tr>
		<td>Joanne</td>
		<td>Laster</td>
	</tr>
</table>
Quote:
Originally Posted by Artie View Post
I would like to generate a paper with simple tables, and export to EPUB. No more than four or five columns with numbers, and some merged cells.
Merged cells are a little more complicated in HTML, and they get QUITE confusing if trying to code them by hand.

You'd have to use this stuff called:
  • rowspan
    • How many merged rows the cell is.
  • colspan
    • How many merged columns the cell is.

Code:
<table>
	<tr>
		<th colspan="2">FullNames</th>
	</tr>
	<tr>
		<td>John</td>
		<td>Smith</td>
	</tr>
	[...]
</table>
What I do is use an external program (like LibreOffice Calc) to design the complicated table, then export to HTML and do my cleanup elsewhere.

(Google Docs should already be fine for this!)

Side Note: Most tools don't export Accessible HTML though, so you'll have to do manual tweaking anyway.

They do dumb stuff like use "<td> + bold it" for headings... instead of using the actual HTML <th>.

The reason why proper HTML is so important is when devices like Text-to-Speech try to read the table:
  • With <th>, they will know WHICH columns are "First Names" + "Last Names".
  • With <td> + bold, they will just think "First" and "Last" is just another row of data.

Last edited by Tex2002ans; 12-02-2021 at 10:42 PM.
Tex2002ans is offline   Reply With Quote