-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CJK font hijacks smart quotes when compiling PDF with XeLaTeX #7509
Comments
Unless you can see a problem with the LaTeX output pandoc is producing, this looks more like a problem with xelatex than with pandoc. Can you post on the tex stack exchange to see if the experts there have any ideas what is causing this, or how to work around it? |
@jgm Thank you for the swift reply! I just tried using pandoc to make a tex file and then manually running xelatex on it. This does not produce the bug. I think with this new information it looks like the problem might be with pandoc after all? |
In producing a PDF via pandoc, we disable the |
Ah, yes, that does produce a tex file that gives full-width CJK quotes when compiled. So this is fully on xelatex then? |
Looks like it's indeed xelatex, specifically the xeCJK package. I got a MWE for it: \documentclass{article}
\usepackage{xeCJK}
\begin{document}
It’s a “bug”!
\end{document} Compiling this with xelatex has the same buggy output with full-width CJK quotes. |
I found this on tex stack exchange: https://tex.stackexchange.com/questions/36878/xecjk-messes-with-punctuation So according to the top answer, this is a feature. That's a problem for users like me, who need to use mixed English and CJK fonts. |
Yes, relatively recent to disable |
Is this a “wontfix” then? |
The only possible fix I can think of is for the PDF module to check to see if the metadata or variables includes |
Just tried lualatex and the bug is still there. |
I'm not sure what ligatures you mean exactly. Is it stuff like |
Ligatures like |
I'm sorry, but I didn't quite understand whether you plan to address this. What would be the issue with using |
I note a possible change to pandoc above, with a possible disadvantage it would have. The reason we don't use the So, if we use Probably it's worth doing, which is why I haven't closed this. |
But what you should do in the mean time is simply generate a standalone tex file (with |
OK, I understand now, thank you. |
I'm not able to reproduce this with my tex setup. Oddly, I can reproduce the issue with your pure latex case. |
Anyway, here's a patch that disables
Since I can't reproduce the issue yet, I'm a bit reluctant to apply this. |
Huh. Well that's weird. Thank you for looking into this. I'm afraid I don't have enough time at the moment to explore this further, but I should be able to help debug this further in a couple of months. I'm running Archlinux on both my machines though, so I can't test with other systems. |
I'm also seeing this bug. Frustratingly, I can't seem to compile my document using the lualatex engine either, as it can't find my CJK font (it's removing the spaces from the font name and then saying it can't find that?) 😞 For those reading this later, you can turn off the smart extension using the |
I also experienced this bug. After some searching around, I found this solution, whereby you reassign the class of the offending characters. I've added this code to my template and find that it's solved the problem: \AtBeginDocument{% |
As per jgm/pandoc#7509 (comment) (somewhat badly formatted due to backticks), the issue of CJK fonts highjacking punctuation in xelatex that has been bothering me for a couple of years can be mitigated. I am applying the fix at the default file level, meaning that every file I compile with `-dpdf` will have it. After a couple of tests, it seems to be working great: PDFs get compiled nicely with no fighting between CJK fonts and smart punctuation. However, the smart punctuation functionality is disabled by default for org-mode input and has to be enabled with `--from=org+smart` when compiling from the command line. The upside of this is that I no longer need to use backticks when writing quotes in org-mode for later PDF generation.
Explain the problem.
When compiling a markdown document with mixed Latin and CJK text and using
--pdf-engine=xelatex
with smart quotes enabled, all single and double quotes become full-width CJK quotes. Basically the CJK font hijacks the smart quotes.From my testing, this happens only with XeLaTeX, and only with smart quotes enabled. This did not happen last year (2020), when I was using pandoc extensively, but I discovered the bug a couple of months ago, and it still persists.
You don't even need to have actual CJK text in the file, simply declaring a CJK font produces the bug.
MWE:
When compiling with
pandoc --pdf-engine=xelatex -i bug.md -o bug.pdf
, the single quote in it's and the double quotes around bug are noticeably wider (full width CJK quotes, from my experience with them). Compiling with other PDF engines or with--from markdown-smart
does not produce these wide quote marks.Pandoc version?
pandoc 2.14.0.2 on Archlinux
The text was updated successfully, but these errors were encountered: