I am writing my thesis in TeXStudio. One chapter features plots / analysis etc. that I am writing in a markdown in RStudio.

Is there a way to kinda "link" the documents so the output from R is displayed in my TeXStudio document and updated automatically in case I change my code in R?

best wishes (:

  • 2
    Hi @rabatz and welcome to TeX-SE. Please verify this answer for python. The command lstinputlisting should work for R too. You should only find some method to apply the desire style you want. For example, there is mcode for Matlab syntax and the link I sent there is a style for python.
    – FHZ
    Commented Feb 22, 2020 at 15:57
  • 1
    @FHZ I am afraid that the question is about show the R output (generated plots, tables, verbatim text results, etc.) rather that just show the R code.
    – Fran
    Commented Feb 23, 2020 at 5:15
  • 1
    Your life will be easier if you (1) rename your thesis.tex as tesis.Rnw and (2) inserting here the R chunks using the syntax <<chunkname, options>>= ... @ instead of ```{r....} ... ``` Or alternatively: (1) convert thesis.tex to thesis.Rmd and then just (2) insert your chapter Rmd in thesis.Rmd. In both cases (3) using only Rstudio to compile the whole thesis.
    – Fran
    Commented Feb 23, 2020 at 5:17
  • For textual output you can use: mirror.marwan.ma/ctan/macros/latex/contrib/rterface/… . // There is no embedded linking to my knowledge, as we know it from MS-Office or from web-server. Update is done when you compile the Latex document.
    – MS-SPO
    Commented Aug 16, 2021 at 10:14

1 Answer 1


If I understood you correctly, you just have to save the plots as pictures (.png, .jpg etc.) in your LaTeX figures folder and open them as usual. You can also specify in LaTeX any other folder on your computer by giving the full path.

\caption[Title of Figure]{Actual Caption. It's nice if you understand the fig. by just reading this caption.}
  • if it is really only a matter of having the plots added, I would suggest saving them as .pdf instead
    – Lukas
    Commented Jun 13, 2022 at 6:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .