R knitr PDF problems with \includegraphics

后端 未结 2 1393
眼角桃花
眼角桃花 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: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
    ---
    

提交回复
热议问题