UniMath / SymmetryBook

This book will be an undergraduate textbook written in the univalent style, taking advantage of the presence of symmetry in the logic at an early stage.
Creative Commons Attribution Share Alike 4.0 International
371 stars 22 forks source link

Producing epub ebooks #123

Closed Iey4iej3 closed 2 years ago

Iey4iej3 commented 2 years ago

I would like to propose a version of simplified codes which could be compiled into epub, which could be subsequently converted into formats readable on eInk devices of which the reading experience is better.

I would like to point out that tex4ebook (https://ctan.org/pkg/tex4ebook?lang=en) allows us to do some basic compilation (so far I succeeded to compile most of papers that I read on arXiv). However, I failed to compile this highly customized book. Here are some comments:

  1. In the preamble, we need to replace ^ by \sp and _ by \sb which are supported by tex4ebook without issue.
  2. \pdfoutput=1 would lead to errors for tex4ebook.
  3. It is better to suppress custom fonts (instead of those of AMS), which are of less mathematical significance.
pierrecagne commented 2 years ago

Full epub format is probably a long shot (epub allows the user to adapt font size and this will surely mess with commutative diagrams for example). But PDF sized for e-reader is a nice idea (I think they did that for the HoTT-Book)

Feel free to fork the repo and make some tests of your own!

Iey4iej3 commented 2 years ago

The diagrams and some of display math are converted into SVG images which are theoretically scalable. There are some nuances about scaling, but I suppose that one does not change the font size beyond a reasonable range (such as smaller than 8pt or greater than 16pt).

I did some tests but failed. It is difficult to debug. The crucial issue seems to be that this document is heavily customized. It is much easier if there is a version of preamble which is simply amsbook without redefining a lot of macros. Most of arXiv preprints don't customize heavily and that is why I usually succeeded to convert them into epub.

UlrikBuchholtz commented 2 years ago

This can probably be fixed by adding another version of macros.tex suitable for tex4ebook. I'm afraid it's not going to be high on our priorities for a while, though. In my experience, math-heavy epubs don't work well at all, but maybe things have improved.

Iey4iej3 commented 2 years ago

Thanks for the response. In fact, the first step should be a very simple version with the preamble similar to

\documentclass{amsbook}
% Theorem environments
\newtheorem
% Customized macros, without \def or \let
\newcommand
\renewcommand

That is to say, without complicated customizations and redefinitions, but the mathematics is not changed. With such a simplified version, the debugging might be much easier (tex4ebook still has some bugs, and I could open issues there) - now I tried some modifications, and after that, I can only see that the epub file is not produced, and the produced html files are incomplete, but there is no error during compilation, and it is difficult to debug.

Iey4iej3 commented 2 years ago

I have just compiled an article (https://arxiv.org/abs/1703.09050) into an epub file which contains several commutative diagrams. Just upload to show the effect, which seems OK for me: BM.zip

UlrikBuchholtz commented 2 years ago

We've now added a Creative Commons license (BY-SA 4.0 since commit 7a5059a), and you're free to continue to experiment with making an epub version. However, I'm going to close this issue, since it's not a priority for us at the moment. (BTW, the file you sent causes my epub reader, Foliate, to crash with a segfault.)

Iey4iej3 commented 2 years ago

The epub file that I uploaded is readable in Calibre, FBReader and Okular, but in FBReader, the commutative diagram is too small, and in Okular, the commutative diagram is fuzzy, but the rendering of Calibre is good for me: 2021-09-17-115956_1303x978_scrot and it is also good after conversion to mobi and sent to Kindle.

Iey4iej3 commented 2 years ago

Related: https://github.com/HoTT/book/issues/287