You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Convert to HTML is fine, but Convert to PDF ignores Greek letters #1673
This has been discussed many time here and on other forums, but I still don't know how to get Jupyter to print Greek letters when I convert the notebook to PDF. Interestingly, if converted to HTML, everything is fine.
When converted to PDF:
When converted to HTML:
I've tried using CLI pandoc and tweaking the settings (e.g., changing the font or using xelatex instead of pdflatex), but nothing seems to work. And since these Greek letters are part of my code, I can't just replace them with something that's known to Latex.
Having unicode letters work in LaTeX differs depending on whether pdflatex or xelatex/lualatex is being used. The current template
For xelatex/lualatex, having \usepackage{unicode-math} in the template would allow for Greek characters to work reasonably in math (but breaks pdflatex). The ucs package isn't needed / is detrimental.
For pdflatex, the current template does include \usepackage[mathletters]{ucs}, but the ucs package also needs \usepackage[utf8x]{inputenc} to come after it, and so with the current template, unicode math won't work.
Pandoc's current template never uses ucs, and uses unicode-math if xelatex/lualatex is being used.
I'll see if I can fix up the template to have this work, hopefully for both math and text.
I haven't looked at this in a while, but I'm fairly certain that we should be using \usepackage[utf8]{inputenc} and not the utf8x package. They are similar, but utf8x dated. I have been meaning to test it out for a while, but I haven't gotten around to it.
I think that \usepackage[mathletters]{ucs} needs utf8x specifically, not utf8; utf8x is actually in the ucs package. I think both ucs and utf8x are dated, yes; for pdflatex, the code here uses the alphabeta package, if it is installed, and only uses ucs and utf8x as a fallback if it isn't. For lualatex/xelatex, it uses unicode-math (though Greek text will not work with the default font in those cases; see #1688).
Activity
MSeal commentedon Nov 17, 2021
Try doing the
webpdfconversion -- it uses HTML to generate the PDF instead of LaTeX and generally has a lot fewer unsupported renderings.ibehnam commentedon Nov 18, 2021
Thanks. I tried that, but it breaks code and code outputs across pages:

cgevans commentedon Dec 7, 2021
Having unicode letters work in LaTeX differs depending on whether pdflatex or xelatex/lualatex is being used. The current template
For xelatex/lualatex, having
\usepackage{unicode-math}in the template would allow for Greek characters to work reasonably in math (but breaks pdflatex). The ucs package isn't needed / is detrimental.For pdflatex, the current template does include
\usepackage[mathletters]{ucs}, but the ucs package also needs\usepackage[utf8x]{inputenc}to come after it, and so with the current template, unicode math won't work.Pandoc's current template never uses ucs, and uses unicode-math if xelatex/lualatex is being used.
I'll see if I can fix up the template to have this work, hopefully for both math and text.
Modernize latex greek math handling (partially fixes jupyter#1673)
t-makaro commentedon Jan 26, 2022
I haven't looked at this in a while, but I'm fairly certain that we should be using
\usepackage[utf8]{inputenc}and not the utf8x package. They are similar, but utf8x dated. I have been meaning to test it out for a while, but I haven't gotten around to it.cgevans commentedon Jan 26, 2022
I think that
\usepackage[mathletters]{ucs}needs utf8x specifically, not utf8; utf8x is actually in the ucs package. I think both ucs and utf8x are dated, yes; for pdflatex, the code here uses the alphabeta package, if it is installed, and only uses ucs and utf8x as a fallback if it isn't. For lualatex/xelatex, it uses unicode-math (though Greek text will not work with the default font in those cases; see #1688).jpgoldberg commentedon Jul 21, 2022
Somewhere, I have get to find where, the generated LaTeX uses latinmodern fonts. latin modern mono does not include Greek.
From my xelatex logs:
I have not found out where I can change this. (I can manually edit the generated LaTeX file, but I want to build from a notebook to PDF