I'm preparing a series of simple document templates on my personal site. To allow readers who have never used pandoc logo to see the visual output, I added some HTML5 logo <object class="responsive-embed"> to allow visual output display of the PDF logo PDF, Word logo DOCX and HTML5 logo HTML from VS code logo Visual Studio Code plugin vscode-pandoc.

screenshot of my page


Thanks to pandoc does not recognize Chinese characters, I know that setting CJKmainfont allows pandoc logo to render CJK characters. However, it breaks the existing greek alphabets in the PDF logo output PDF.

screenshot of my page's PDF embed
Click the above screenshot to view HTML5 logo my page.


The above sample documents are produced on another device. To let you see the undesirable visual output, I've prepared two MWEs.

group target control
Markdown source file name cjk_article.md article.md
Greek alphabets in file content
CJK characters in file content
mainfont Times New Roman Times New Roman
CJKmainfont Noto Sans CJK SC absent
CJK characters rendered
Greek alphabet spacing

I've chosen standalone instead of article for documentclass in order to produce PDF files that will be converted to PNG with pdftoppm, so that the steps and output are reproducible.

$ diff -u {,cjk_}article.md
--- article.md  2023-04-08 12:59:46.415084100 +0200
+++ cjk_article.md      2023-04-08 13:02:34.029625600 +0200
@@ -1,6 +1,7 @@
 documentclass: standalone
 mainfont: Times New Roman
+CJKmainfont: Noto Sans CJK SC

-Section Ωαβ.  Lôrém ipsùm dolor sit amet.
+Section Ωαβ.  Lôrém 繁體 ipsùm 简体 dolor こんにちは sit 조선글 amet.

During the compilation, I hadn't installed the dependencies, so MikTeX's on-the-fly installation was invoked for the following pakcages:

  • xeCJK MikTeX's on-the-fly installation of xeCJK
  • luatexja-fontspec.sty MikTeX's on-the-fly installation of luatexja-fontspec.sty
  • everyhook.sty MikTeX's on-the-fly installation of everyhook.sty
  • svn-prov.sty MikTeX's on-the-fly installation of svn-prov.sty
  • UniJIS2004-UTF32-H MikTeX's on-the-fly installation of UniJIS2004-UTF32-H
  • HaranoAjiMincho-Regular.otf MikTeX's on-the-fly installation of HaranoAjiMincho-Regular.otf

I clicked "Install" so as to install the missing packages. The system complained about the missing font "NotoSansCJKSC", which I immediately installed.

$ find -path './*article.md' -print0 | \
> while IFS= read -r -d '' file; do
> pandoc --pdf-engine=lualatex $file -o ${file%md}pdf
> done
Error producing PDF.
! Package fontspec Error: The font "NotoSansCJKSC" cannot be found.

For immediate help type H <return>.

l.27   \fi

Git Bash error
MikTeX Console noto
In my MWE, I'm using Noto Sans CJK SC instead of Noto Sans CJK TC in an answer for the linked TeX.SE question due to the name of the highlighted LaTeX package in the above screenshot.

After that, I repeated the above command, and the error message was gone. To produce observable results (to be included in the next section), I used pdftoppm (shipped with my MikTeX's installation).

$ !find
find -path './*article.md' -print0 | while IFS= read -r -d '' file; do pandoc --
pdf-engine=lualatex $file -o ${file%md}pdf; done
$ find -name '*article.pdf' -exec sh -c \
> 'f="{}"; pdftoppm -png -r 450 "$f" "${f%.*}" 2>/dev/null' \;
$ which pdftoppm

Remarks: thanks to this helpful one-liner for {} placeholder manipulation on Unix.SE. I suppressed the following warning message with 2>/dev/null.

MiKTeX requires Windows 10 (or greater): https://miktex.org/announcement/legacy-windows-deprecation


Here're the output PNG for

  • target group (✓ CJK)

    target group output

  • control group (✗ CJK)

    control group output

To view pdftoppm -png's output in their original dimensions, I suggest clicking on these images to view their in a separate tab.


How can I get the correct spacing between the greek alphabets (illustrated in the screenshot for the control group's output) with CJK characters (shown in the screenshot for the target group's output)?

desired output
Remarks: the above screenshot is made with MS Paint.


1 Answer 1


Thanks to the adopted answer of How do I use accented latin letters + russian + japanese in the same document? (mentioned by @JavierBezos in the comments), I've found the line that resolves this problem.


pandoc provides the header-includes variable in which I can include this line of code.

Regarding the lines


I don't include them in that pandoc variable because it's already there in pandoc's default template, which loads the LaTeX package iftex.

The configurations for sansfont and monofont aren't the main focus of this problem. I've found that these variables are redundant in the following MWE.

babel-lang: english
babel-otherlangs: chinese, japanese, korean, greek 

Including and/or excluding these two lines won't affect the final result. pandoc's user manual provides more detailed info about the lang and babelfonts variable.


documentclass: standalone
mainfont: Times New Roman
CJKmainfont: Noto Sans CJK SC
header-includes: |

Section Ωαβ.  Lôrém 繁體 ipsùm 简体 dolor こんにちは sit 조선글 amet.


output figure

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .