Thread: Tables in ePub
View Single Post
Old 12-06-2021, 04:47 PM   #16
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 Hitch View Post
Perhaps I'm misunderstanding something then.

How is it you expect to 'create a table' if not with an HTML editor like Sigil or Calibre? I'm unclear on what you're expecting. If you did use Word and exported to HTML, yes, you'd get an HTML table. Apparently, you don't wish to do that.

[...]

So, in short--you want/need HTML tables, but you seem to not want to use the tool that will export that, in HTML, to a file format that you can then use to make an ePUB.

Is that right?
That's how I'm understanding it too... baffling.

1. Tables are super important to me.

2. All these crappy programs I'm choosing to use don't handle tables...

Well, then that's on you! Ask those programs to add proper tables support or change your workflow.

- - -

Side Note: A similar situation happened with a book I worked on a few years ago.

The author was writing a Non-Fiction book, nearly a thousand footnotes + URLs + citations... and someone bamboozled him into trying Scrivener, because they told him:

"I hear it's the best at making books!"

... No.

He wasted lots of time trying to wrestle with Scrivener, trying to force it to do something it wasn't designed to do.

(Luckily, he fell back on Word + someone taught him how to properly use Styles! He became one of the rare 1%!!!)

Quote:
Originally Posted by Hitch View Post
Word, for all its alleged issues (which are non-existent if you clean the file properly and use Styles and headings, I might add) is a perfectly straightforward way to make HTML tables. I don't know if Libre Office does the same thing, but others here will know.
Yep. Same exact thing in LibreOffice (that's what I use to recreate/export trickier tables):

1. File > Export as XHTML
2. Clean up XHTML cruft
-- (Bring it down to barebones <table>, <td>, <th>, [...])
3. Copy/Paste HTML into the EPUB.

Because LibreOffice carries over a ton of inline fonts/widths/alignment/crap...

I usually just do these two regular expressions:

Find: style="[^"]+"
Replace: ***BLANK NOTHING IN HERE***

Find: class="[^"]+"
Replace: ***BLANK NOTHING IN HERE***

Example Table

Code:
First   Last
Joe     Brownstone
Tex     Testerson
LibreOffice XHTML:

Spoiler:
Code:
  <table border="0" cellspacing="0" cellpadding="0" class="ta1">
    <colgroup>
      <col width="99"/>
      <col width="99"/>
    </colgroup>

    <tbody>
      <tr class="ro1">
        <td style="text-align:left;width:0.889in; " class="ce1">
          <p>First</p>
        </td>

        <td style="text-align:left;width:0.889in; " class="ce1">
          <p>Last</p>
        </td>
      </tr>

      <tr class="ro1">
        <td style="text-align:left;width:0.889in; " class="Default">
          <p>Joe</p>
        </td>

        <td style="text-align:left;width:0.889in; " class="Default">
          <p>Brownstone</p>
        </td>
      </tr>

      <tr class="ro1">
        <td style="text-align:left;width:0.889in; " class="Default">
          <p>Tex</p>
        </td>

        <td style="text-align:left;width:0.889in; " class="Default">
          <p>Testerson</p>
        </td>
      </tr>
    </tbody>
  </table>


but after running those 2 regex, it's much more reasonable:

Spoiler:
Code:
  <table border="0" cellspacing="0" cellpadding="0">
    <colgroup>
      <col width="99"/>
      <col width="99"/>
    </colgroup>

    <tbody>
      <tr>
        <td>
          <p>First</p>
        </td>

        <td>
          <p>Last</p>
        </td>
      </tr>

      <tr>
        <td>
          <p>Joe</p>
        </td>

        <td>
          <p>Brownstone</p>
        </td>
      </tr>

      <tr>
        <td>
          <p>Tex</p>
        </td>

        <td>
          <p>Testerson</p>
        </td>
      </tr>
    </tbody>
  </table>


You can then strip down that HTML further:

Spoiler:
Code:
  <table>
    <thead>
      <tr>
        <th>First</th>
        <th>Last</th>
      </tr>
    </thead>
    
    <tbody>
      <tr>
        <td>Joe</td>
        <td>Brownstone</td>
      </tr>
      <tr>
        <td>Tex</td>
        <td>Testerson</td>
      </tr>
    </tbody>
  </table>


(Create a "Saved Search" Group in Sigil or Calibre, and this multi-step Word/LibreOffice <table> cleanup can be a one-button process.)

- - -

Side Note: You can also use LibreOffice (or Excel) to transpose tables very easily.

(Flipping wide tables from "horizontal" to "vertical".)

Very important in ebooks, since you have "infinite" vertical space, but very limited horizontal. (You can scroll up/down forever, but it's a pain in the neck to go left/right if something flows off the screen.)

Transposing is discussed in the table threads I linked previously + the linked threads below.

Quote:
Originally Posted by Artie View Post
And I think this GIF is brilliant! Super! https://old.reddit.com/r/gifs/commen...less_terrible/


Quote:
Originally Posted by Artie View Post
I started this thread to figure out which is the best workflow for tables inside an EPUB file.
You could read all types of workflows (and tips/hiccups) here:

It pretty much boils down to these stages:
  • Input format -> Intermediate cleanup -> Output format

for example:
  • DOCX -> EPUB (Dirty) -> EPUB (Clean)
  • InDesign -> EPUB (Dirty) -> EPUB (Clean)
  • PDF -> [DOCX -> EPUB (Dirty)] -> EPUB (Clean)

Every conversion/stage is going to bring its own unique troubles:
  • EPUB -> HTML
    • Like chapters from an ebook -> articles on a website.
    • How do you deal with links to other chapters?
    • Will your document transfer over cleanly? The website will usually have completely different CSS.
  • HTML -> EPUB
    • Like articles from a website -> ebook.
    • Complex CSS (like CSS3 Counters) won't work in ebooks. You'll have to "hardcode" in <ol> lists.
    • Fonts, font sizes, and lots of other formatting won't carry over nicely, so you can't just copy/paste the CSS from the site.
  • InDesign -> EPUB
    • InDesign exports "iBooks-friendly" EPUBs, but lots of that complex CSS doesn't work on other ereaders.
  • PDF -> EPUB
    • Footnotes? Floating tables? Floating figures?
  • [...]

Source (Master) Documents

And every person/publisher is going to have a preferred format.

They will make all their changes in the master document, then export to the other formats from there.

So you can have:
  • "HTML-first" workflow
  • "InDesign-first" workflow
  • "Word-first" workflow
  • "EPUB-first" workflow
  • [...]

This also complicates the situation.

- - -

Side Note: Read about the "bifurcation" I discuss in the above threads.

Once you split the file into multiple formats, each correction/change will multiply the total amount of labor + potential errors.

If the author magically decides to make 100 extra changes since you created the ebook... now you have to correct:
  • 100 in the Print
  • 100 in the EPUB
  • 100 in the HTML
  • [...].

so you want to squash these corrections EARLY and as thoroughly as you can.

- - -

My Workflow

Personally, I go with an "EPUB-first" workflow.

I get everything into HTML+EPUB as soon as possible:

then use my EPUB as the master source file for everything else:

Step 1. Anything -> EPUB
Step 2. Clean with Sigil/Calibre
Step 3. EPUB -> Anything

But if you work within a team, and require other source formats, you'll have to adjust.

Anyway, like Hitch said, Word/LibreOffice/GoogleDocs and tons of other writing tools already support HTML tables... so I don't see the issue.

Quote:
Originally Posted by Artie View Post
I don't want to use images for tables (and maths formulas).
Formulas. Images, sadly, are the only way:

MathML isn't well supported, so you have to fallback to images anyway.

But long-term thinking is key. You can create formulas in ways where you can easily export to MathML in the future.

(I currently use LaTeX as my source for formulas. This allows me to easily automate generation of new/higher-quality images + export to MathML in the future.)

Quote:
Originally Posted by Artie View Post
Likewise, I'm confused about how Calibre and Sigil may help me, can you please elaborate a little more on that @Kalleen?
Sigil + Calibre's Editor are EPUB editors.

These let you powerfully edit the HTML... while also making your EPUB-life infinitely easier by taking care of all the EPUB-specific things... like:
  • splitting chapter files
  • reordering chapters by drag/drop
  • renaming files + updating all internal links
  • generating Table of Contents
  • inserting/attaching Cover files
  • Metadata Editor
    • Add title, author, publisher, ISBN, publication date, [...]
  • [...]

along with tons of other super helpful tools/enhancements:

Last edited by Tex2002ans; 12-07-2021 at 06:07 AM.
Tex2002ans is offline   Reply With Quote