1

I am trying to place two figures from .pgf file input side-by-side. I want them to have independent captions (so no subfigures). I have tried using the minipage way as follows:

\documentclass{article}
\usepackage{pgf}

\begin{document}

Some words..
\begin{figure}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \input{figure1.pgf}
        \label{Figure1}
        \caption{This is caption for Figure 1.}
    \end{minipage}
\end{figure}
\begin{figure}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \input{figure2.pgf}
        \label{Figure2}
        \caption{This is caption for Figure 2.}
    \end{minipage}
\end{figure}

\end{document}

But instead of getting them side by side, I get them one below the other, like the attached picture. Tried using \scalebox{0.6} before \input the pgf but still the same behavior.. I have tried many different combinations and I can't find a way to make this work...enter image description here

EDIT: This is not a duplicate. I am importing .pgf files. My latex code is identical to the above answer but it doesn't work. pgf files are here if someone needs to test.

  • No it is not, my latex code is identical to that answer. I am also importing .pgf files, not image files. – bomberb17 Feb 10 at 5:17
  • 1
    You should give the full compileable code that starts with \documentclass and ends with \end{document}. As well as the code that generates the .pgf files – AndréC Feb 10 at 5:20
  • 1
    (i) images can be side-by side, if they are small enough (ii) to put them in parallel, they should be in the same float environment. – Zarko Feb 10 at 5:28
  • @ AndreC: here are all the files a.uguu.se/DPFft8cqVVmz_code.7z – bomberb17 Feb 10 at 5:55
  • @ Zarko: Tried to use \scalebox{0.3}{\input{figure1.pgf}} they become very small but still not in the same row. – bomberb17 Feb 10 at 6:01
1

It turns out that I had to remove the two intermediate \end{figure} \begin{figure} and enclose everything into the same figure. So the code now looks:

\documentclass{article}
\usepackage{pgf}

\begin{document}

Some words..
\begin{figure}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \scalebox{0.45}{\input{figure1.pgf}}
        \label{Figure1}
        \caption{This is caption for Figure 1.}
    \end{minipage}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \scalebox{0.45}{\input{figure2.pgf}}
        \label{Figure2}
        \caption{This is caption for Figure 2.}
    \end{minipage}
\end{figure}

\end{document}

enter image description here Thanks also to Johannes_B and AndréC for helping!

  • I'm a little bit confused. Apart from the file extension, the main difference between the code in your question and that in the accepted answer to the alleged duplicate was precisely the \end{figure}+\begin{figure} that you've now removed. – Circumscribe Feb 10 at 21:25
  • That, and the use of \scalebox. – Circumscribe Feb 10 at 21:32
  • Yes I was just going to write that. It turns out you have to use \scalebox for .pgf files. – bomberb17 Feb 10 at 21:34
  • 1
    You could also try \resizebox{\linewidth}{!}{\input{figure1.pgf}}. That scales the figure to precisely the width of the minipage. See the documentation for graphicx. – Circumscribe Feb 10 at 21:35
  • Yes I confirm this works as well – bomberb17 Feb 10 at 21:36

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.