TikZ in R Markdown

前端 未结 2 1577
伪装坚强ぢ
伪装坚强ぢ 2020-12-25 08:00

R Markdown is a good tool for document authoring. It can use LaTeX statement in R Markdown directory. But when I try to insert a TikZ picture, I am lost about how t

2条回答
  •  轮回少年
    2020-12-25 08:49

    This is a example about how to use tikz graph in R Markdown within R Studio

    ---
    title: "Hello World"
    author: "Me"
    date: "February 17, 2015"
    output:
      pdf_document: default
    header-includes: 
      - \usepackage{tikz}
      - \usepackage{pgfplots}
    ---
    
    ## TikZ picture
    - Here is a TikZ picutre
    
    \begin{tikzpicture}
    \draw (0,0) circle (2cm);
    \end{tikzpicture}
    
    - Here is another TikZ picutre
    
    \begin{tikzpicture}
    \begin{axis}[xmax=9,ymax=9, samples=50]
      \addplot[blue, ultra thick] (x,x*x);
      \addplot[red,  ultra thick] (x*x,x);
    \end{axis}
    \end{tikzpicture}
    

    Output:

提交回复
热议问题