1
votes

I have to put all my code from a Rmarkdown document into pure LaTeX format in Overleaf. For this reason, I can't use my knitr code anymore to produce latex tables right away, but I need to write the LaTeX code by myself.

I through, although kable/kableExtra do now show LaTeX code in RStudio, the code must be produced in the background to make LaTeX able to read it.

Now my question: Is there any option to let me see the full LaTeX code produced by kable/kableExtra in order to take it and copy it into my pure LaTeX document?

I would be happy to hear your suggestions.

Best, Moritz

1
Try using the argument format="latex" in kable, e.g. knitr::kable(df, format="latex")henrik_ibsen
Thanks @henrik_ibsen! I did that and it works fine when I render the code in RStudio because Rmarkdoan automatically converts the code into Latex. However, I can not see the code, the process runs in the background. My question is how I can see the latex code an take it to copy it into another LaTeX editor.xm0riTzx

1 Answers

2
votes

There are different ways to get to the .tex file from an .Rmd file.

  1. Convert only to LaTeX by using in your YAML header

    ---
    [...]
    output: rmarkdown::latex_document
    ---
    
  2. Convert to PDF but keep the LaTeX file by using in your YAML header

    ---
    [...]
    output: 
        rmarkdown::pdf_document
            keep_tex: yes
    ---
    

I prefer the second approach since it allows for previewing the document easily while editing the .Rmd file. Note that there are other output functions besides rmarkdown::pdf_function that support the keep_tex argument.