6

I would like to know how can I put two diagrams on the same like rather than one of the top and one at the bottom. which consumed too much space on the paper. Here are the codes for the figure which I used.

  \begin{figure}[!htb]\centering
     \frame{\includegraphics[width=10cm]{Data1}}
     \caption{Interpolation for Data 1}
  \label{Fig:Data1}
  \end{figure}

  \begin{figure}[!htb]\centering
     \frame{\includegraphics[width=10cm]{Data2}}
     \caption{Interpolation for Data 2}
  \label{Fig:Data2}
  \end{figure}
4
  • I think that is difficult since the width of the images are 10cm each, meaning it is wider than the page width, or are you using landscape?
    – rtzll
    Jan 9, 2013 at 8:33
  • You have to make subfigures with the 'subfig' package. Please see the answer to (tex.stackexchange.com/questions/83664/inserting-subfigures)
    – TeXtnik
    Jan 9, 2013 at 8:33
  • @ChristianR. - What width do you think I should put for both to fit on the same line? I have been working on two graph whereby the second is a replica of the first with shorten range and domain to give a clearer picture at certain spots. So I would like both to appear on the same line if possible.
    – Sandra
    Jan 9, 2013 at 8:49
  • @zunbeltz - tried that as well but its not working. I even modified the width to 5cm each and still no luck. But I do receive the caption of both diagrams as (a) and (b).
    – Sandra
    Jan 9, 2013 at 8:56

2 Answers 2

6
\documentclass{article}
\usepackage[demo]{graphicx}% delete [demo] later
\begin{document}

\begin{figure}[!htb]\centering
   \begin{minipage}{0.49\textwidth}
     \frame{\includegraphics[width=\linewidth]{Data1}}
     \caption{Interpolation for Data 1}\label{Fig:Data1}
   \end{minipage}
   \begin {minipage}{0.49\textwidth}
     \frame{\includegraphics[width=\linewidth]{Data2}}
     \caption{Interpolation for Data 2}\label{Fig:Data2}
   \end{minipage}
\end{figure}

\end{document}

put them in one figure environment without an empty line between. The % is important here.

17
  • No it didn't work out.
    – Sandra
    Jan 9, 2013 at 8:48
  • sure, 10cm +10cm is too wide for a line. Try it with width=0.49\textwidth
    – user2478
    Jan 9, 2013 at 8:51
  • I just tried this and not sure why but this didn't workout.
    – Sandra
    Jan 9, 2013 at 9:06
  • didn't workout is not a very useful description of your problem ...
    – user2478
    Jan 9, 2013 at 9:11
  • sorry! What I meant is my diagram is still like the usual one of top and one at the bottom even applying the width to 0.49.
    – Sandra
    Jan 9, 2013 at 9:13
3

I changed the width to fit it on a page, the total width you can use is dependend on the documentclass.

I would use subfigures as follows (for the image I used the tex.sx logo):

Code

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{5cm}            
\frame{\includegraphics[width=5cm]{Data1}}
\caption{Interpolation for Data 1}
\label{Fig:Data1}
\end{subfigure}
%
\hspace{1cm}
%
\begin{subfigure}[b]{5cm}
\centering
\frame{\includegraphics[width=5cm]{Data2}}
\caption{Interpolation for Data 2}
\label{Fig:Data2}
\end{subfigure}
\caption{Interpolation}\label{fig:TOF}
\end{figure}
\end{document}

Output

image

6
  • I tried this and my graph become rather small. Do you think it is possible to make it big while ignoring the margins of the paper? And eventhough it works, the subcaption package clash with my small caption package. So when I removed the small caption package, then it works but the caption become like normal size text.
    – Sandra
    Jan 9, 2013 at 9:04
  • @Sandra I'm not familiar with the small caption package so I can't help you there, but with the page width you could use the ¸geometry package, which allows you to set specific page margins.
    – rtzll
    Jan 9, 2013 at 9:10
  • Thanks for your assistance though. I may have to use your method if other methods didn't workout even if the graph is rather small to be read considering there are three functions in one graph.
    – Sandra
    Jan 9, 2013 at 9:15
  • @Sandra Maybe you can tweak it a bit also using the height argument, as so: [width=5cm,height=5cm]. I'd say try various values and see what is closest to what you want.
    – rtzll
    Jan 9, 2013 at 9:19
  • Thanks. The function's lines and the points on the x axis is still not very clear. Not sure if it is Mathematica faults as my graphs were done using Mathematica. The previous 10cm which I used is not very clear too but still can be read when printed using laser printer. When adjust to 5cm width and height, the lines when printed, blurr out.
    – Sandra
    Jan 9, 2013 at 9:30

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