0

I have exported several images using matplotlib into .pgf files but I am having trouble organizing them together in my latex document. This is the best I can get:

\begin{center}
\begin{tabular}{cc}
 \input{toy_gauss.pgf}
 &
 \input{toy_gauss2.pgf}
\end{tabular}
\label{Fig:gauss}
\end{center}

But this yields one image too big causing the other to be caught off: enter image description here

Also I tried using \figure env for this type of graphic and they throw errors so that's why I am using tabular here. I really just want two pgf images beside each other. (maybe even having four images in a 2x2 formation but one step at a time.)

guy
  • 205
  • 2
  • 4
  • 2
    Why not try using \resizebox{\textwidth}{!}{\hbox{\input{a.pgf}\input{b.pgf}}} instead of using a tabular environment? – domperor Jul 30 '20 at 03:58
  • 1
  • 1
    Your problem is that the figures are too large, set the size in matplotlib before saving as pgf. – Torbjørn T. Jul 30 '20 at 07:48
  • @domperor Your solution worked the best. Anyway to add (a) and (b) automatically beside the figures? So you can refer to them as figure 3-b or figure 2-a? – guy Jul 30 '20 at 17:33
  • Usually if you really want the automatic, you would need to write some macros; this comment space is too narrow for them (maybe it would be better for u asking this as another question). But the difficulty depends on the class you are using.... – domperor Jul 31 '20 at 08:50

1 Answers1

2

Use one figure environ for both inputs -- https://latex.org/forum/viewtopic.php?t=32239

\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}

js bibra
  • 21,280
  • As mentioned, the figure env doesn't work for me so I cannot test your solution. – guy Jul 30 '20 at 19:12
  • 1
    @guy For the support of js bibra's answer.... Popular LaTeX document classes (e.g. article, book,... ) contain the figure environment. What kind of class are you using? Maybe it is better for u to give a minimum working example that begins with \documentclass{...} and end with \end{document}. This would make it easy for the community to help you in a precise way. – domperor Jul 31 '20 at 08:11
  • @guy How to make a “minimum working example”: https://www.texfaq.org/FAQ-minxampl – domperor Jul 31 '20 at 12:25