For example, I have this Markdown document:
## Markdown test
Japanese 日本語
I run:
pandoc mwe.rmd -t beamer -o mwe.pdf --latex-engine=xelatex -V mainfont=MS\ Mincho
The words 日本語 simply disappeared in the resulted file. If I don't use the Beamer template then it works correctly.
I don't have to use pandoc
. Anything that gets me from Markdown to PDF (slides) on a Mac (with MacTex) would work for me.
If there is no easy solution, I'd be okay with anything that results in non-Beamer PDF slides.
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