Open slacka opened 11 years ago
When I looked into this in the past, the results with "mobi" and "ePub" are difficult to achieve and faulty. LaTeX just isn't meant to generate them.
I use PDFs on my iPad Mini. The book looks fine, but the font is small. If I have the time, I'll look into tuning the page format for a smaller screen. (less margins, larger font, but keep images the same size.)
http://tex.stackexchange.com/questions/16374/effort-to-make-latex-ebook-friendly
http://tex.stackexchange.com/questions/3070/preparing-pdf-files-for-ebook-readers-etc
On Fri, Jun 21, 2013 at 10:56 AM, slacka notifications@github.com wrote:
Would be great for those of us with e-book readers. Thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/HoTT/book/issues/287 .
In the meanwhile we prepared hott-ebook.pdf
with small margins. Please use that until someone figures out how to typeset math for ebooks.
Dandy!
On Fri, Jun 21, 2013 at 1:44 PM, Andrej Bauer notifications@github.comwrote:
In the meanwhile we prepared hott-ebook.pdf with small margins. Please use that until someone figures out how to typeset math for ebooks.
— Reply to this email directly or view it on GitHubhttps://github.com/HoTT/book/issues/287#issuecomment-19811309 .
I've figured out how to typeset maths for ebooks ...
But it's definitely non-trivial to convert a LaTeX file to ePub. I got something that compiled, but needs some work to make it a true ePub version.
I will buy you a beer if you can do this.
To give you a flavour of what it might look like (and also to show where work would need to be done) here's the introduction as an ePub:
http://www.math.ntnu.no/~stacey/documents/HoTT-introduction.epub
This is a valid ePub3 with mathematics embedded as MathML. It opens in iBooks, but some of the glyphs are missing (as are the references, but that's because it's just the first chapter). There are probably lots of other oddities that someone familiar with the text would spot.
The big issue (which is common to any LaTeX-to-non-fixed-format conversion) is that there are things where you have to work out "What do I want this to be like in the final document?" and the answer isn't always the same for PDF as for XHTML (including ePub) as PDF is a visual, fixed layout format and XHTML isn't.
But fortunately, this is perhaps something that is easy to do via a collaborative effort. If I can get the backbone working then others can put the flesh on it by figuring out the figures and replacements for missing glyphs and so forth.
Would it make sense to have a separate branch for this? How much will we have to "pollute" the source to get epub working?
Inevitably some messing with the main text will be necessary (particularly with diagrams). At the moment I'm trying my best not to mess with the actual text and just handle things at the macro level.
Though I'm coming up against some issues with your ... creative ... use of the equation environment! I might have to rewrite those as I've not found a way to embed ordinary text inside mathematics and still have full range of text.
Technical bit: the equation environment signals maths, so we start a MathML piece. Text within that gets put into an mtext tag, but you then want emphasised text within that and the naive
\begin{equation}\label{eq:tautology1} \text{\emph{``If not $A$ and not $B$, then not ($A$ or $B$)''}.} \end{equation}
Technically here, the outer mathematical environment is doing nothing. But an automated system still sees it.
An alternative would be to have a textequation environment which centres its contents and sticks the equation label exactly as the equation environment does, but doesn't go into maths mode.
For that sort of thing we probably don't care whether it really is a math environment. It just has to look kind of the same.
A very simple version would be:
\newenvironment{textequation}{\equation\hbox\bgroup}{\egroup\endequation}
I am inclined to start this off as a fork first, and then pull it in when we can be sure it's working. I imagine you already have a fork. I'll follow you there, and here maybe you can post a link to it for people who are interested in coperation.
Or we make a branch. I am not sure which is The Correct Thing to do in this case.
I guess the reason to make this a math environment was to get it an equation number. On Jun 21, 2013 10:53 AM, "loopspace" notifications@github.com wrote:
A very simple version would be:
\newenvironment{textequation}{\equation\hbox\bgroup}{\egroup\endequation}
— Reply to this email directly or view it on GitHubhttps://github.com/HoTT/book/issues/287#issuecomment-19830773 .
Here are some samples generated using pandoc (v1.11.1 compiled with texmath 0.6.1.3):
$ pandoc -t epub3 -f latex -o ~/Dropbox/HoTT/hott-intro-pandoc.epub introduction.tex
https://www.dropbox.com/s/saxm6cdqnjccd8g/hott-intro-pandoc.epub
$ pandoc -t epub3 -f latex -R -o ~/Dropbox/HoTT/hott-intro-pandoc-raw.epub introduction.tex
https://www.dropbox.com/s/hmoan0vzio2u5o9/hott-intro-pandoc-raw.epub
Any macro debugging will help all of these efforts. The best github way to do this would probably be to create an "epub" feature branch in your project. Contributors would still use forks and pull requests to submit changes to the "epub" branch, and whichever work pans out can later be merged into the master branch on the official project.
The textequation that I gave above will get an equation number.
I foresee two types of changes needed to get an epub version. Some changes are things that can be done on the main version and have no effect there but make life easier for conversion scripts (such as mine or pandoc). These are things like the textequation environment, and changing underscores in reference names to hyphens.
Others will be things that are specific to an epub version.
I'm currently working just on my own machine. I'll create a github fork sometime soon and make it a bit more official. I wanted to see if it were even possible before doing anything serious.
Right, here's what I've gotten today. It's everything up to the appendix, apart from the fact that I've blanked out a few things that I know are going to be tricky (diagrams mainly) and there are a few symbols that I can't find in the unicode list. It opens in Azardi, I haven't tried it in iBooks yet. There are validation errors, mostly due to references but a few due to maths in the section titles.
I've uploaded a new version to the above link which does open in iBooks on an iPad. It contains all the sections up to the appendix.
This loks very promising! On my ipad in iboks there seem to be missing math fonts.
@andrejbauer Yes, it would appear that iBooks doesn't come with enough fonts to cover the unicode range. Fortunately, it is possible to embed fonts in an epub. I've just replaced the above version with one with the main STIX fonts embedded (the STIX licence allows this, I believe) and that fixes a lot of the missing glyphs. There's still some missing (integral signs and the like) because I didn't embed the full STIX family on the first go as I didn't know if it would work.
Anyway, try it again from http://www.math.ntnu.no/%7Estacey/documents/HoTT-main.epub
It is using German gothic letters instead of mathsf, weird. I am still amazed at how quickly you got this far.
Oh, that's because I was lazy and couldn't remember off the top of my head what mathsf looked like so I set it to mathfrak for the time being.
Hmm, the bit that actually does the conversion to MathML doesn't yet know about mathsf. I've set it to mathrm for the time being and will look into adding that later.
New version uploaded (same link as above), now includes bibliography.
Things that need work:
I have created a proper fork for this project now. I'm new to git/github so I may get things horribly wrong!
The stuff in formal didn't take too much (though it could probably be made better). Latest version has that in as well. Tables also (though the colours in the homotopy groups of spheres aren't as yet). So indexing and figures are the main missing bits.
On a Cybook e-reader, there are still a lot of symbols missing, for instance \to, \mathbb{N}, \equiv, \simeq, \top, \bot, \vee, \wedge … Not all of them are missing, for instance greek letters, \times, \infty, \int are present (yes, there are some integral signs in the book ^^). Also, indices and exponents do not seem to work (but maybe this e-reader does not understand MathML)
@guillaumebrunerie There aren't that many ebook readers that can cope with MathML so it wouldn't surprise me that it didn't work. I know that iBooks has rudimentary support, and there are some desktop readers that work as well (Azardi does, Calibre has MathJaX embedded). Sorry about that.
If you're seeing integral signs, then the markup you're getting might just be a symptom of it being a work in progress.
MathML is part of the newer ePub 3.0 standard, so look for e-reader software that supports it.
(New version just uploaded.)
Yes, definitely a work in progress! I've just uploaded a screenshot to G+ showing that at certain font sizes then it renders very curiously. I suspect that I need to embed more fonts, probably the entire STIX family.
I just tried it out in the Firefox ePub reader add-on and it looks much better than in iBooks (superiority of Gecko's MathML rendering over Webkit's I guess) which suggests that there is a limit to how good this is going to get.
It’s a bit strange that MathML is mandatory for ePub 3 but not the mathematical fonts. What is MathML good for if you can’t display any mathematical symbol?
My understanding is that MathML isn't mandatory for ePub3 but that ePub3 works on a modular system so it's possible for an ebook reader to say "We support the core of ePub3" without actually supporting MathML.
For iBooks then MathML support is almost an accident. iBooks is based on Webkit and so when something is supported in Webkit then it automatically gets supported in iBooks. But that doesn't mean that they've deliberately thought about it in great detail (I'm not saying they haven't, just that it needn't follow). Given that its support in Webkit is no where near Gecko's, I guess the rationale is that there's no point embedding a slew of fonts until it is more developed.
But I'm guessing on most of this. It might just be that I don't yet know how to make it use the fonts correctly. It certainly looks okay in the Firefox epub reader with no missing glyphs (well, hardly any).
I have downloaded the epub version from the link that loopspace posted 8 days ago to my Sony PRS T2 ebook reader. Most formulas look o.k. but a) no subscripts or superscripts, e.g. in the formula for ISO(A,B) in the section on constructivity from the introduction, everything is on one line. \pi_1 or x^2 is rendered on one line, like "x 2" (But footnotes ARE shown as superscripts.) b) certain missing symbols are shown as a crossed-rectangle, for example mathcal-U (in particular) and mathbb-S (but not mathbb-Z),
Besides c) The math fonts are upright and not italic. d) displayed equations are left-aligned. e) equation numbers appear as 1.2.1 instead of (1.2.1) in the book, both where they are defined and where they are cited (but there they are highlighted as hyperlinks) f) there are boxes around theorems, lemmas and proofs etc. g) there is no table of contents h) figures are missing.
I have also looked at it with the FBReader program on a Linux computer, and there it did not look better (the layout is even worse, equation numbers are on the left, tables are not usable at all)
Let me take your comments one-by-one. (Incidentally, I keep updating the book but the link stays the same. The current version dates from June 28th.)
a) This is a sure sign that your ebook reader doesn't support MathML. There's not a lot I can do about that! The superscripting for footnotes is actually done via normal CSS not MathML so I'd actually be more surprised if they didn't work. b) I was having a few issues with fonts and how font selection should work. I'm not sure that fixing this will fix the missing glyphs for you but just in case I've uploaded the most recent version. Some of the more popular mathematical symbols (such as mathbb-Z) have made their way into "ordinary" fonts but for the full range then you need something like the STIX fonts. As they tend not to be available on most devices (is there any that has them?) then I've embedded them in the book. But if your reader doesn't support embedded fonts then there's nothing I can do. c) Might be the font selection issue, might be lack of support for MathML. MathML puts single tokens in italics by default so the CSS doesn't need to specify that. If the MathML is being ignored, all the reader sees is, say "x" not "x-in-italics" so renders it in normal font. d) Should be centred. e) Where they are defined then they should have parentheses around them (not sure about cited). But the parentheses are inserted by CSS (the :before and :after pseudo classes) so if the reader doesn't support them then it won't render them. f) Yes, I put those in as an experiment. I find it helps me see where proofs and theorems end. g) Should be there, but ePub3 and ePub2 have different methods for tables of contents so if your reader is basically saying "Well, it's sort of like ePub2 so I'll have a go" then I'm not surprised this is missing. h) Not yet done.
On a computer, you can try either azardi or the epub add-on for Firefox to see what it ought to look like.
New version uploaded (same link as above). The symbol index and regular index are now in place.
Question for anyone still reading: in the PDF, the index links back to the page on which the index entry was made. In an eBook we can link to the same place but we don't know the actual page number since that can change depending on user settings. What should the link text be in this situation? That is, in the actual index it might say:
category 126
where 126 is the page number and is hyperlinked to where the index entry was defined. But in the ebook, it might not be page 126. We can't know what page it will be on but we need some text there to provide something to click on. What should that text be?
need /some/ text there to provide something to click on. What should that text be?
Could the link be the entry itself? (without anything additional to click on)
Hadn't thought of that.
I'm not sure it would work. For one thing, one index entry might have several places to link back to (∞-category has about a dozen). For another, the indexed entry might be a bit complicated (for example, contain mathematics) and I'm not sure how well that would interact with being a link.
I'm not sure it would work. For one thing, one index entry might have several places to link back to (∞-category has about a dozen).
That's a point. How about parapgrah or section numbers, like §1.2, §1.2, §3.2.1. Like page numbers, they give the reader a hint whether several occurrences are close together or spread over different parts.
(And remember there is always the fall-back option of writing "click here", "click here", "click here", "click here"
I think section numbers seems like the best choice.
Turned out that the easiest was to use \cref
to reference the "enclosing block", whatever that might be. So if the indexed entry was in running text you might get "Chapter 2" but if in a definition you'll get "Definition 3.1.7". The link goes to wherever the label was, though.
I need to do the same for the symbol index.
Symbol index done (I changed the definition of \pg
to \cref
).
This is not about an epub version but a PDF version for ebook readers. (related to issue #290) I have prepared one for myself and put it at http://page.mi.fu-berlin.de/rote/Kram/hott-EB.pdf
It has the following features.
I found myself frustrated over flipping back and forth over a theorem or formula that straddles page boundaries. The bottom third of the screen is now devoted to a preview of the next page. I remember seeing mediaeval books or manuscripts where the first or syllable or word of a page was repeated at the end of the last page. I wonder how long it will take me to get used to reading in this mode; for pure text it is not so usual. The ideal would rather be a long continuous scroll, but that does not work on my reader. But maybe math is not good for ebook readers anyway.
I guess you were unsatisfied with hott-ebook, which is like the printed ustrade version without the margins? We (particularly @andrejbauer) decided that we're not willing to "officially" maintain versions with more than two different text width setttings, as each new such setting requires going through the entire book to adjust the line breaks and so on.
The repetition is an interesting idea! I'm not sure what I think about that.
It was quick hack, and it has some quirks: When an html link goes across a page boundary, the whole page becomes the clickable area. References from TOC or index jump to the previous page of the intended target, and the heading on the top of the page is the appropriate one for the next page. Still, I like it better than hott-ebook, but it is definitely not suitable as a "production" version. (What about adapting the height of hott-ebook? You don't have a lot of figures and such about whose placement you need to worry. I don't know on what other devices people read hott-ebook, but 4:3 seems to be a typical aspect ratio.
What I would still like is to jump from the index to the right place, not to the top of the page. (like in loopspace's ebook version)
I just noted that the lines of hott-ebook are just a tiny bit longer than in my version; I will look into that (And there is an index entry for "anger". is that a joke.
I'm not very skilled with formatting issues, but maybe @andrejbauer can have a look when he gets back from his vacation.
(yes.)
There does not seem to be many updates on this topic, but I would like to mention that tex4ebook
has been improved much during the last a couple of years. It works well if the preamble is not complicated. You could see an example in https://github.com/UniMath/SymmetryBook/issues/123#issuecomment-918416659 and https://github.com/UniMath/SymmetryBook/issues/123#issuecomment-921671535
@loopspace Your link seems to no longer work. Is your work (and how to generate it) available somewhere?
@JasonGross I haven't done anything on this for a long time, but my fork is still available at https://github.com/loopspace/book. It needs the internet
class, which is now available at https://github.com/loopspace/internet . I have updated that considerably since 2013 so I can't guarantee that it will still compile without further adaptation.
@JasonGross I haven't done anything on this for a long time, but my fork is still available at https://github.com/loopspace/book. It needs the
internet
class, which is now available at https://github.com/loopspace/internet . I have updated that considerably since 2013 so I can't guarantee that it will still compile without further adaptation.
The later link to the internet
class seems broken. Anyway, did you compare this with tex4ht
(the frontend is make4ht)?
Sorry, I meant:
https://github.com/loopspace/latex-to-internet
If it still works, it would be compiled with lualatex. It doesn't use tex4ht as I wanted something more flexible than that when I developed that class.
I wanted something more flexible
Do you remember what? I wonder the shortages of tex4ht
.
I originally developed my internet
class to write article for the nlab. This accepted a markdown variant with a LaTeX-like syntax for Mathematics. But it didn't allow macros, so I couldn't do - for example - \def\R\mathbb{R}
. That was irritating, so I wanted to be able to write something in LaTeX and have it output in the right format for that software. Eventually, I settled on using a LaTeX class since "the only thing that understands TeX is TeX itself" (I've previously attempted to write LaTeX parsers in php and perl so I know the truth of that!). Over time, I added capability to it to output a variety of different text outputs. At the moment, my main use is to maintain my website (https://loopspace.mathforge.org). So when the question arose of converting HoTT to epub, I already had all the tools available and didn't need to consider anything else.
So it's not really a drawback of tex4ht
, rather that I originally had a different end-goal and then my class gradually extended so that it overlapped a little with tex4ht
.
Would be great for those of us with e-book readers. Thanks!