What to do about cross-references in an exported EPUB

I have some pre-existing ODT documents that up until now have only ever been exported to PDF, and I am now also exporting them into EPUB. I love that LibreOffice has this built-in. I am very impressed. Was previously using OpenOffice, and have just moved over and loving it so far!

Since these documents are “designed” for PDF, they have a large proliferation of cross-reference links, e.g.:

For more details see “interesting chapter” on page 27.

This arrives in the EPUB as:

For more details see “” on page .

I am looking for advice on how to handle this and hoping that the advice isn’t “just delete all your cross-references”. I can imagine it might be worth deleting all the “on page x” parts of the cross references, because really those are only useful if people are PRINTING out the PDF on actual PAPER! :smiley:

But I would like to find a way to get the link text to remain if EPUB doesn’t support links (is that the case? I don’t know), just so that the sentence still reads OK.

Of course, the ideal would be for cross-references to still work in EPUBs too, but I don’t know whether that is actually supported by EPUBs - it’s all quite new to me.

All advice gratefully received.
Am using Libre Office Version: 25.8.1.1 (X86_64)
Build ID: 54047653041915e595ad4e45cccea684809c77b5
CPU threads: 22; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-NZ (en_NZ); UI: en-GB
Calc: CL threaded

I am viewing EPUBs using a MOON+ reader on a Samsung Phone at the moment, but would also be happy to hear about othe readers that people love - the idea is to make these EPUBs available for a large audience to read.

Cheers,
Morag

First, I never exported to EPUB, so I’ll be of little help.

The EPUB specification states that it is basically XHTML. Consequently, all HTML features should be available in EPUB, notably <a … > elements. It then all depends on how the export filter handles the cross-references. There is also an EPUB publication about Canonical Fragment Identifiers (CFI) which defines how to encode target locations within the document. Once again, this is the responsibility of the export filter to make the correct translation.

Could you attach a 1- or 2-page .odt sample containing a cross-reference and the corresponding EPUB? To attach the EPUB, you may be forced to cheat the AskLO site: just add an .odt or .pdf extension at end of the file name.

You could try Writer2xhtml extension, https://extensions.libreoffice.org/en/extensions/show/writer2xhtml to see if that works better. The user manual, on page 37 says it can do some links that Writer can’t.
Footnotes and endnotes work though so it is surprising that bug tdf#128955 hasn’t been resolved.

You could convert fields to text in LibreOffice.

Maybe Calibre can convert from pdf?

Hi @ajlittoz,

Attached is an example ODT and the EPUB generated by the built-in LibreOffice export as EPUB. As you rightly noted, the upload wasn’t allow, so I have changed the file extension to .PDF - rename the file to .EPUB again before using.

I hope this is what you were requesting and it aids you in understanding the issue at hand. It would be marvellous if the in-built LibreOffice EPUB generator was able to handle cross-references regardless of what might be available as add ons.

Cheers,
Morag

Example CrossRef.epub.pdf (3.5 KB)

Example CrossRef.odt (47.4 KB)

HI @EarnestAl,

Thank you for the pointer - I have tried the Writer2xhtml LibreOffice extension, and you are quite right, it does an excellent job of the cross references, and also I have to say, a much better job of flowing the text around images - the built in one tries to wrap too tight, and overlays the edges of images sometimes. This is likely my solution for now, although I would be keen to see the built-in EPUB be improved.

wrt your suggestion of converting from PDF, do you think that it is likely something starting from PDF rather than starting from the original source will do a better job of creating a flowing text EPUB? I have the source, and am creating both a PDF and an EPUB (hopefully) so I naively imagine that this is the best starting point. I am happy to make changes to the source to improve the output where required.

The first exported EPUB version I made, with no tweaks to the source at all, using the Write2xhtml extension is fair (probably better than fair), and might be good enough, but I think I will go and tidy up a few styles in the source so that things are more “vanilla” and I think I will get an even better EPUB as a result.

I thank you all for your help on this topic, and if I can assist in some way to improve the LibreOffice built-in, please just ask.

Cheers,
Morag

1 Like

I have not exported anything to EPUB except for testing. I found my Kindle was fine for reading text-only books but referring to illustrations was problematic.

Maybe Calibre opens .odt natively, I did not check, sorry.

That is a setting for the frame style in LibreOffice. Frame styles are easily direct formatted by the mouse however so care and planning is needed.

Here is a starting point, Get Involved | LibreOffice - Free and private office suite - Based on OpenOffice - Compatible with Microsoft

Thanks for the “get involved” link @EarnestAl - I followed that through and found the place where defects are reported, and this particular behaviour is already captured in a defect from 2019 (see 128955 – Inserted cross-reference text is disappear on exported EPUB file). The most recent comment seemed to be asking for confirmation that the bug was still present, so I have provided that confirmation and linked to my other reply to @ajlittoz with the example ODT and EPUB which might be some help to the developers.

Thanks for all the engagement with a new forum member. Your help has very much been appreciated.

Cheers,
Morag

I had a look at the sample files. I think the export filter is the culprit. The cross-reference is not included in the EPUB XHTML (completely skipped). At this stage, I can do no more because I am not competent in this area.