例如,我有这个Markdown文档:
## Markdown test
Japanese 日本語
我跑:
pandoc mwe.rmd -t beamer -o mwe.pdf --latex-engine=xelatex -V mainfont=MS\ Mincho
单词日本语在结果文件中消失了。如果我不使用Beamer模板,那么它可以正常工作。
我不必使用pandoc
。在Mac(使用MacTex)上从Markdown到PDF(幻灯片)的任何东西对我都有用。
如果没有简单的解决方案,我会对任何导致非Beamer PDF幻灯片的内容感到满意。
答案 0 :(得分:3)
I'm assuming that you do have installed a font named MS Mincho
on your system, and it shows up when your start the Font Book.app
? (Looks like, otherwise your "normal" PDF output wouldn't work, but you said it does...)
There are various options to check and verify, which exact font name you should use.
Font Book.app
(GUI application)Font Book.app
.mincho
into the top right search box.i
-logo.From the font's metadata you can infer the PostScript name
and the Full name
of the font. Both should work with XeLaTeX. (I usually put quotes around font names with spaces: -V mainfont="YuMincho Medium"
Here is a screenshot with the relevant parts of the Font Book.app
UI highlighted in red. Sorry, I do not have MS Mincho
installed, I can only show it with another font:
fc-list
(command line utility)fc-list
is a command line utility that is available via the MacPorts fontconfig
package.To get a list of font names available for XeTeX, you can simply run:
fc-list -f "%{family}\n"
fc-list :outline -f "%{family}\n"
The second command suppresses the listing of bitmap only fonts. Such fonts are unusable for TeX. -- For some more verbosity, and a nice formatting of the info, you could also run:
fc-list :outline -f " family: %{family}\nfullname: %{fullname}\n file: %{file}\n\n"
To get a list of names containing 'Mincho', run:
fc-list -f "%{family}\n" | grep -i mincho
Now that this smaller problem ("Which font names should I use?") is out of the way, lets deal with your main one:
\setmainfont
command. Therefor putting -V mainfont=...
onto the Pandoc command line does not do anything.You can check this by querying the default internal template used by Pandoc to produce beamer output:
$ pandoc -D beamer | less
Search for a $mainfont$
variable in there and you'll find none!
You have to modify your setup a bit to get success:
First, create a simple text file named mincho.tex
with the following two lines of content (I'm using my Mincho font name here, so I can really test if my advice will work):
\usepackage{xeCJK}
\setCJKmainfont{YuMincho Medium}
The xeCJK
package is required by XeLaTeX for supporting Japanese (and Chinese+Korean) fonts.
Second, add -H mincho.tex
to the command line so the above code snippet is included into the LaTeX code generated by Pandoc.
This is the complete command to convert your Markdown to Beamer-PDF:
pandoc \
mwe.rmd \
-t beamer \
-o mwe.pdf \
--latex-engine=xelatex \
-H mincho.tex
Result (screenshot):
The fonts used by the Beamer-PDF are these:
$ pdffonts mwe.pdf
name type encoding emb sub uni objID
----------------------------------- ------------ ----------- --- ----- ---- -----
TZVOMD+LMSans8-Regular-Identity-H CID Type 0C Identity-H yes yes yes 7 0
WMSBXQ+LMSans12-Regular-Identity-H CID Type 0C Identity-H yes yes yes 30 0
FXCTKJ+LMSans10-Regular-Identity-H CID Type 0C Identity-H yes yes yes 32 0
NXJKDD+YuMin-Medium-Identity-H CID Type 0C Identity-H yes yes no 34 0