R knitr PDF problems with \includegraphics

后端 未结 2 1374
眼角桃花
眼角桃花 2021-01-07 21:27

Using a new empty .rmd document, this code works:

![](RainbowDolphin.png)
\\begin{center}
\\includegraphics[width=4in]{RainbowDolphin.png}
\\end{center}


        
相关标签:
2条回答
  • 2021-01-07 22:19

    You may let Pandoc know that you have graphics in this document by specifying the YAML metadata:

    ---
    graphics: yes
    ---
    
    0 讨论(0)
  • 2021-01-07 22:22

    It's because the latex template doesn't load the graphicx package by default. You can do it manually by adding this to the yaml header:

    ---
    title: "Untitled"
    header-includes: \usepackage{graphicx}
    output: 
        pdf_document:
            keep_tex: true
    ---
    
    0 讨论(0)
提交回复
热议问题