-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Can not add lang zh-CN when convert md to pdf by xelatex #7945
Comments
I think that this change to the default latex template should do the trick: diff --git a/data/templates/default.latex b/data/templates/default.latex
index 3874813c7..438f84690 100644
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -368,7 +368,9 @@ $if(lang)$
\else
\usepackage[bidi=default]{babel}
\fi
+$if(babel-lang)$
\babelprovide[main,import]{$babel-lang$}
+$endif$
$for(babel-otherlangs)$
\babelprovide[import]{$babel-otherlangs$}
$endfor$ |
Note: this change will bypass babel for Chinese, relying only on xeCJK. |
When I change the code so that
is generated, the document compiles but we get "?abstract?" instead of a Chinese localization. Not sure why. |
One way to get the localization of "Abstract" is to use the ctexart documentclass instead of article. Add this to your pandoc invocation:
|
@jgm thanks, I only add documentclass config as follows, it works doc:
cmd:
I got the correct Chinese localization of "Abstract", "Figure" and so on. But I don't know how that works, I don't tell pandoc anything of which language need to use,it output Chinese automatically ? For example, I want to output a mix of Chinese Simplified and Chinese Traditional document,“Abstract“” localization us zh-Hant(Chinese Traditional), and how to configure the markdown metadata ? |
The default template includes
so it is detecting CJKmainfont and loading xeCJK for that reason. Maybe that package can figure out the language by looking at the characters? I'm not sure, actually. Maybe looking at the documentation for xeCJK https://ctan.org/pkg/xecjk will reveal something you could pass in with CJKoptions? Oddly, Chinese + its variants seems left out of the mappings defined in Text.Pandoc.LaTeX.Lang. Is there a reason? Well, when I tried above to add Chinese manually, I didn't get the right localized abstract, so maybe someone figured out that it works best just to include xeCJK without using babel? This is something I'm really ignorant about: could anyone out there who is familiar with babel and Asian languages help out? |
From my limited experience, CJK is in practice handled very differently in LaTeX comparing to other languages. The ctexart is I believe from the CTeX package. CTeX specialize in producing Chinese documents (so not general CJK) but it seems it is what you're after. I recommend reading the CTeX documentation for their recommended practices (and adapt to pandoc using the template.) For the question
It is because ctex is specialized in Chinese documents so by choosing the document class you already inform what language you are after. |
Thank‘s for everyone, After your guidance, I know |
pandoc version: 2.17.1.1
Steps to reproduce:
this works well:
doc:
test.md
cmd:
the output pdf:
Error condition:
when I add
lang: zh-CN
(or similarlylang: zh-HK
,lang: zh-Hans
,lang: zh-Hant
) as follows:It fails:
It looks like pandoc unable to set correct language parameters to babel, I wonder how to set them correctly!
I test this on
windows10
andwindows7
with latest version ofMiKTeX
andTeX Live
, the errors were consistent.pandoc version: 2.17.1.1
tex version: MiKTeX-TeX 4.4 (MiKTeX 22.1)
latex version: MiKTeX-pdfTeX 4.10 (MiKTeX 22.1)
xelatex version: MiKTeX-XeTeX 4.7.1 (MiKTeX 22.1)
I really need to set the language to Chinese for abstract title or figure legend ...
Thanks to anyone for helping me !
The text was updated successfully, but these errors were encountered: