美文网首页
RStudio Beamer pdf中文输出问题

RStudio Beamer pdf中文输出问题

作者: 学着放下 | 来源:发表于2021-03-07 12:52 被阅读0次

    参考文章
    http://yufree.github.io/blog/2016/09/19/beamer-in-chinese
    https://brucezhaor.github.io/blog/2016/06/30/chinese-beamer/
    项目地址:https://github.com/BruceZhaoR/Zh-beamer
    如果不想看本文,直接git

    请务必在使用前先安装tinytex相关的包 详见我的另一篇博文
    https://www.jianshu.com/p/f51db4d26377

    不能显示中文的原因

    Why Chinese would not display? This issue happens at the last step. By default, some templates such as beamer in RStudio use pdflatex. However, you might need CJK package. However you would need to use CJK environment to display Chinese. I don’t think it is a good way and you need to write ugly documents.

    xeCJK package would be preferred because you only need to set up the font for your Chinese and you will get the output. However, such configuration need you use xelatex to compile you documents.

    For the beamer template in RStudio, they use pdflatex. So the first way to show Chinese is telling Pandoc to use xelatex other than pdflatex. You could set up such command in the yaml.

    The second issue is the font. When you use xelatex(actually xeCJK package), you need to set the font for CJK charactors such as Chinese. Maybe you could try the following yaml to use a font without sources.
    以下任何一个方式都可以解决

    字体方式解决

    ---
    title: "中文测试"
    author: "Yufree"
    date: "2016年9月19日"
    CJKmainfont: FandolFang
    output:
      beamer_presentation:
        latex_engine: xelatex
    ---
    

    yaml设置方式解决(强烈推荐该方法)

    Not everyone knows how to find the right name of a font. However, the updated ctex package solved such problem. They use some default setting to avoid the font issue. All you need to do is use the ctex package for your tex template.

    We might also use yaml:

    ---
    title: "中文测试"
    author: "Yufree"
    date: "2016年9月19日"
    header-includes:
      - \usepackage{ctex}
    output: 
      beamer_presentation:
        latex_engine: xelatex
    ---
    

    相关文章

      网友评论

          本文标题:RStudio Beamer pdf中文输出问题

          本文链接:https://www.haomeiwen.com/subject/fxxyqltx.html