I can include my R plots in a LaTeX document using tikz package (on the LaTeX side) and tikzDevice package on the R side. I produced many .tex files containing my plots in R using as an example the following code in R:

tikz(file = 'BarplotScreenType.tex', width = 3, height = 3)
barplot(height=table(screentype),main="", xlab="Types of screens",  ylab="Count", ylim=c(0,12),  col="blue")

What I need to do is to include all these .tex files in a nice border-less table of images in the LaTeX document. I previously used a piece of code (shown below) that allowed me to put png images using \raisebox{-.1\height}{\includegraphics[width=0.5\textwidth, height=0.3\textheight, inner]{AchavanichOriginalCROPED1}}:

\caption{Table showing decimated images of Achavanich Beaker(original 
resolution was 6.1M faces - 1st picture on left)}\label{table:images}
height=0.3\textheight, inner]           
{\includegraphics[width=0.5\textwidth, height=0.3\textheight, inner]
{Achavanich3MCROPED3}} \\
 height=0.3\textheight, inner]


height=0.3\textheight, inner]{Achavanich750KCROPED2}} \\

[width=0.5\textwidth, height=0.3\textheight, inner]

{-.1\height}{\includegraphics[width=0.5\textwidth, height=0.3\textheight, 

{Achavanich100KCROPED}} \\

\includegraphics does not support .tex as an extension even .tex files contain a blocks of \tikzpicture commands.

Another important thing: I need a caption for each figure and a label (for cross referencing...).

Any ideas of how that might be done? Any better suggestions would also be greatly appreciated!


Use \input instead of \includegraphics. Do not forget to set the proper width and height of your graphic chunks


tikz(file="cars.tex", width=2, height=2)
plot(cars, xlab="", ylab="")

  \input{cars} & \input{cars}\\
  \input{cars} & \input{cars}

enter image description here

  • Boris Kindly, how do I put a caption and label so I can reference it from LaTeX side? Do you know? If I put the "\include{}" like the following " \begin{figure} \include{graph1} \caption{M1} \label{fig:M1} \end{figure}", I receive an error.
    – HB87
    Mar 20 '17 at 15:08
  • Sorry, I figured out the solution. Using the package \usepackage{subcaption} and inside the table I can then put the following form: \begin{subfigure}{0.4\textwidth}\centering \include{barplotGraph} \caption{Figure A: Graph 1} \label{fig:taba} \end{subfigure}
    – HB87
    Mar 20 '17 at 15:21
  • Great. There are several ways to do this; this is a good one.
    – Boris
    Mar 20 '17 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.