Tables and Figures side-by-side in Knitr or RMarkdown Beamer

后端 未结 4 2075
北海茫月
北海茫月 2020-12-31 12:58

I am trying to create a Beamer Presentation slide in RMarkdown / Knitr . In the slide I would like to have a table and a figure placed Side-by-side , and then some more text

4条回答
  •  一生所求
    2020-12-31 13:22

    There have been issue having two column layout in beamer presentation. But in the same post there is workaround:

    In short: Error is related to pandoc conversion engine, which treats everything between \begin{...} and \end{...} as TeX. It can be avoided by giving new definition for begin{column} and end{column} in yaml header.

    Create mystyle.tex and write there:

    \def\begincols{\begin{columns}}
    \def\begincol{\begin{column}}
    \def\endcol{\end{column}}
    \def\endcols{\end{columns}}
    

    In the Rmd file use these new definitions

    ---
    output:
      beamer_presentation:
        includes:
          in_header: mystyle.tex
    ---
    
    
    Two Column Layout 
    -------
    
    \begincols
      \begincol{.48\textwidth}
    
    This slide has two columns.
    
      \endcol
    \begincol{.48\textwidth}
    
    ```{r}
    #No error here i can run any r code
    plot(cars)
    ```
    
      \endcol
    \endcols
    

    And you get:

提交回复
热议问题