marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.03k stars 799 forks source link

Fix Latex compilation errors #327

Closed skotniczny closed 6 years ago

skotniczny commented 6 years ago

It seems to work almost well

skotniczny commented 6 years ago

Notice that currently compilation fails after apple emoji in the line: "The problem is that the 🍎 in the first line is treated as two code"

Besides in this case i would use Inconsolata with Cyrillic glyphs as mono font

marijnh commented 6 years ago

What problems do the changes solve? The book currently builds for me, and the Chinese characters and apple are visible. FandolSong, for some reason, fails to load on my machine even though I've installed it via texlive-lang-chinese.

skotniczny commented 6 years ago

Please compile document with this line, it will be clear. \defaultfontfeatures[\emojifont]{Color=FF0000}

marijnh commented 6 years ago

Where should I look for the problem? The apple example and the mixed script one still look the same with that line added.

skotniczny commented 6 years ago

Look, after apple emoji - font size, quotation marks and dashes are broken

screenshot-2018-2-14 eloquent_javascript pdf

screenshot-2018-2-14 eloquent_javascript pdf 1

marijnh commented 6 years ago

Still not sure what you mean. In trying to build with your changes, I am getting font errors. What way of installing FandolSong and CMU Serif do you recommend?

skotniczny commented 6 years ago

Try with direct path, for exapmple i use \newfontface{\emojifont}{Symbola_hint.ttf}[Path=/usr/share/fonts/truetype/ancient-scripts/] and \setmonofont[Path=/usr/share/fonts/truetype/inconsolata-lgc/,Scale=0.8]{Inconsolata-LGC}

marijnh commented 6 years ago

Ohh, I see what you mean now, after that point all quotes are messed up. That's awful. Trying to find a chinese font that actually works now.

marijnh commented 6 years ago

Tried some fonts, but they all look worse than what I had before. What are the reasons for the changes to the handling of the Chinese text?

skotniczny commented 6 years ago

I guess, because now it work without errors. :( For example images also works even with bad syntax for \usepackage{graphicS}

marijnh commented 6 years ago

Right. Errors or not, I've reverted a few changes to make the Chinese text look better, and merged the rest of your changes. Thanks for helping out with this! I'm quite clueless when it comes to LaTeX.

marijnh commented 6 years ago

Oh, it seems that now the balloon emoji is screwing up all text after it. This is great.

marijnh commented 6 years ago

And that is indeed caused by the changes I made to the CJK font handling... which is bizarre, since the problem is a long way from the Chinese characters.

skotniczny commented 6 years ago

Definitely it is not case better or worse looking fonts, they look like that because when compilation pass properly LaTeX set it monospaced at any cost. When compilation fails, characters are displayed in normal manner.

marijnh commented 6 years ago

Using Inconsolata LGC does simplify things a bit. For some reason (doesn't seem to be the font's fault) the Greek letters get a bigger letter spacing even though they are using the same font, so that's not looking great, but I don't care too much.

In patch 5dabfda47f I also changed to an approach where I leave lst for Chinese, Arabic, and emoji text, since it seemed to be impossible to get those to render in a good looking way in listings. The result looks better (but is rather fragile).

There's still a bunch of errors in the log that I don't understand, but the output look okay.

skotniczny commented 6 years ago

Try add π φ β ≈,

\usepackage{newunicodechar}
\newunicodechar{π}{$\pi$}
\newunicodechar{ϕ}{$\varphi$}
\newunicodechar{≈}{$\approx$}
\newunicodechar{β}{\ss}
marijnh commented 6 years ago

Oh, good point, added in eb33c5d