Why in plots,plot can't correctly display chinese

Someone who knows more about CJK in LaTeX may be able to simplify this:

using PGFPlotsX

# run this just once, to setup PGFPlotsX
PGFPlotsX.latexengine!(PGFPlotsX.PDFLATEX)
push!(PGFPlotsX.CUSTOM_PREAMBLE, raw"\usepackage{CJKutf8}",
      raw"\newcommand{\zh}[1]{\begin{CJK}{UTF8}{gbsn}#1\end{CJK}}")

# the actual plot
p = @pgf Axis({title = raw"\zh{图形}" }, Plot(Coordinates(enumerate(rand(10)))))

# we also save it
pgfsave("/tmp/test.pdf", p)

4 Likes