Including images in a report is very common. Structuring your work nicely is probably the most obvious reason why you want to put two figures/tables side-by-side. Another reason might be to save space, wherever a smaller size of an image is sufficient. The following code can be used to place two figures side-by-side by creating a minipage…
\begin{figure}[ht]
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[scale=1]{filename1}
\caption{default}
\label{fig:figure1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[scale=1]{filename2}
\caption{default}
\label{fig:figure2}
\end{minipage}
\end{figure}
Note that for JPEG images the graphics package is required:
\usepackage{graphics}
The same “local column” – effect can be achieved for tables. The following code shows you how:
\begin{table}[ht]
\begin{minipage}[b]{0.5\linewidth}\centering
\begin{tabular}{|c|c|c|}
\hline
1&1&1\\
\hline
2&2&2\\
\hline
\end{tabular}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{tabular}{|c|c|c|}
\hline
1&1&1\\
\hline
2&2&2\\
\hline
\end{tabular}
\end{minipage}
\end{table}
You can also have more than two column simply by adding another \minipage in between the table-command and reduce the width of each \minipage (0.33\linewidth for three columns) in addition to the \hspace. LaTex will automaticaly place objects onto the next line, if space is not sufficient.
Remark: Using the subfigure-package is another way to place figures or tables side-by-side. You might want to have a look at this post on subfigures.
Tags: article, book, code, figure, LaTex, minipage, report, table, tabular
August 4, 2007 at 1:22 pm |
I was wondering if you had any tips on the creation of tables in LaTeX? This seems to be the most frustrating (to me) task. Ideally, I’d like a GUI table generator that converts the table into LaTeX.
In any event, great blog!
August 11, 2007 at 4:09 am |
[...] have posted another article on that, just have a look there. minipage can also be used for text, not only for figures and [...]
August 28, 2007 at 2:33 pm |
[...] within the usual figure-floating-environment. You can find a post on the minipage-environment here, behaving differently compared a subfigure, but is also used within a floating [...]
September 11, 2007 at 3:56 am |
PLLEEEEASE help me:
I would like to create a table in Latex and add it a note at the end of the table and the source where I got that table from. How can I add those lines of text at the end of the table?
Thanks,
Miguel
September 11, 2007 at 4:11 am |
Hi Miguel,
If I understand correctly, you can simply use the \caption{table description} command. Just make sure you place it before the \label{}. This post shows you how:
http://texblog.wordpress.com/2007/08/07/introduction-to-tables-in-latex/
Cheers,
Tom
September 11, 2007 at 2:49 pm |
Hi Thomas,
This is how I would like my table to look in Latex (for example):
Table 1. This is my table title
_____________________________
1970 2000
_____________________________
GDP 3.5 5.4
Inflation 2.0 4.1
_____________________________
Note: this values are not true.
Source: World Bank (2003).
I don’t have problems with citing inside the table. That works fine. But my problem is how to add the note and the source at the end of the table. I’ve tried different options, nothing works (i.e., minipage) and it looks horrible. I wonder if there is an automatic option to do that. Double caption wouldn’t work because there would be two “Table #”, I gather.
What do you think?
Miguel
September 11, 2007 at 3:28 pm |
You might want to try using the table itself to hold the note and source. Try this:
\begin{table}[ht]
\begin{minipage}[b]{0.48\linewidth}
\caption{Table 1. This is my table title}
\centering
\begin{tabular}{lcc}
\hline
&1970&2000\\
\hline
GDP&3.5&5.4\\
Inflation&2.0&4.1\\
\hline
\multicolumn{3}{l}{Note: this values are not true.}\\
\multicolumn{3}{l}{Source: World Bank (2003).}\\
\end{tabular}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.48\linewidth}
\caption{Table 1. This is my table title}
\centering
\begin{tabular}{lcc}
\hline
&1970&2000\\
\hline
GDP&3.5&5.4\\
Inflation&2.0&4.1\\
\hline
\multicolumn{3}{l}{Note: this values are not true.}\\
\multicolumn{3}{l}{Source: World Bank (2003).}\\
\end{tabular}
\end{minipage}
\end{table}
If you need vertical lines to separate cells, instead of the horizontal bar in the column-number defining tabular-environment option, you can use \vline
Example:
\vline&Inflation&\vline&2.0&\vline&4.1&\vline\\
It’s a lot more to type, but this way you can omit the vertical lines around the note and source.
September 14, 2007 at 9:53 am |
I’m looking for a way to place a picture next to a table. Do you have any idea on this?
September 14, 2007 at 11:07 am |
Ok, after some tries I could solve it myself. Here is the solution:
\begin{table}[h]
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{fig1}
\caption{caption fig1}
\label{fig:fig1}
\end{minipage}
~\hfill~
\begin{minipage}{0.45\textwidth}
\centering
\begin{tabular}{|c|c|c|}
moin & moin & moin\\
\end{tabular}
\caption{caption tab1}
\label{tab:tab1}
\end{minipage}
\end{table}
Thanks,
Amir
September 27, 2007 at 5:46 pm |
To all those with difficulties making tables:
If you’re comfortable with a program like OpenOffice.org Calc or Excel or whatever, you can use that program to make your tables.
If you Google for “Excel table macro Latex” or something like that, you can find a macro to convert the table to a LaTeX table.
AFAIK Excel2Latex is also usable for this kind of conversions.
October 15, 2007 at 5:34 pm |
i want side caption for figures in two column job and also bottom allignment
October 30, 2007 at 3:03 pm |
Hey thanks … found your minipage stuff pretty useful
November 1, 2007 at 10:49 pm |
@ashokg
This is not that easy actually. You can try the minipage-command, by using this Latex-source stab it worked perfectly well for me:
\begin{figure}
\centering
\begin{minipage}[t]{0.58\linewidth}
\includegraphics[width=1\linewidth]{figure-file}
\end{minipage}\hfill
\begin{minipage}[b]{0.38\linewidth}
\caption{Whatever caption-text you want.\label{fig:caption}}
\end{minipage}
\end{figure}
The most important thing here is the bottom-alignment of the right-hand side “minipage” ([b]). The linewidth of the figure is 1 in order to use the complete width provided by the “minipage”.
Cheers,
Tom.
November 3, 2007 at 6:10 pm |
Hey
For some reason, I can’t get the minipage environment to place my tables side-by-side. Here’s the source:
\begin{table}[h]
\begin{minipage}[b]{2.25in}
\centering
\caption{}
\begin{tabular}{@{}|l|c|c|}
\hline
& \hearts & $\lnot$\hearts\\
& (0.2) & (0.8)\\
\hline
$A$ & &\\ fold hand & $-\$78$ & $-\$78$\\
\hline
$B$ & &\\ call raise & $+\$x$ & $-\$228$\\
\hline
\end{tabular}
\label{table3}
\end{minipage}
\begin{minipage}[b]{2.25in}
\centering
\caption{}
\begin{tabular}{@{}|l|c|c|}
\hline
& \hearts & $\lnot$\hearts\\
& (0.2) & (0.8)\\
\hline
$A$ & &\\ fold hand & $-\$y$ & $-\$y$\\
\hline
$B$ & &\\ call raise & $+\$231$ & $-\$228$\\
\hline
\end{tabular}
\label{table4}
\end{minipage}
\end{table}
Any ideas why this won’t work? Thanks.
November 3, 2007 at 6:11 pm |
@David
Just remove the space between the two minipage-environments and the tables are placed side-by-side, as long as there is enough space vertically. If you want some space between, you can comment the empty line out
\end{minipage}
%
\begin{minipage}
Tom.
November 3, 2007 at 6:15 pm |
Miguel (or anyone else wondering about this)
I’ve placed additional text at the bottom of my tables using a custom command I call ‘\capbot’ (caption bottom)
\newcommand{\capbot}[1]{%
\vspace{8pt}\footnotesize\raggedright #1}%
I then use this command in the table float as follows:
\end{tabular}
\end{center}
\capbot{Data from the IMF’s website: \url{http://www.imf.org/external/np/sec/memdir/members.htm.} Accessed 11 April 2007.}
\label{nondemocfig}
\end{table}
This works quite nicely.
January 3, 2008 at 7:45 am |
Thanks, this article helped me a lot!
January 30, 2008 at 9:28 pm |
How to create a big table across a two-column latex document? I tried vertically put the big table in one column for the two-column latex document. But it looks ugly so I tried \minipage. However, it still does not help. Any suggestions?
February 4, 2008 at 6:02 pm |
Hi Kai,
What I suggest you to do is use the command \onecolumn, which will start a new page having only one column in your “two column environment” (see my previous post).
Then you insert your table, depending on the height/width ratio you can even change the page layout to landscape.
And finally, you switch back to a \twocolumn environment.
Cheers,
Tom
February 6, 2008 at 11:39 am |
Hi,
Is it possible to have the two figures/tables aligned at the top stead at the bottom? I’ve tried \minipage[t] but it ended up with the top of the left figure/table aligned to the bottom of the right one. It looked as if the two figures/tables occupied the top right and bottom left of a 2×2 invisible grid.
Thanks
March 5, 2008 at 5:54 am |
Hi Si,
I had the same problem once I wanted to place a table next to a figure. Try to use subfigure instead of minipage, I’m not sure it will work, but it is worth a try.
Note:
Replace \begin{center}…\end{center} by \centering, which does not add any additional white space on top and below the figure/table.
April 14, 2008 at 7:08 pm |
[...] width of a page. Even though you can have several figures/tables next to each other (see posts on minipage and subfigure), with none of these techniques it is possible to have floating text around a figure [...]
April 15, 2008 at 11:02 am |
[...] width of a page. Even though you can have several figures/tables next to each other (see posts on minipage and subfigure), with none of these techniques it is possible to have floating text around a figure [...]
April 15, 2008 at 7:38 pm |
[...] within the usual figure-floating-environment. You can find a post on the minipage-environment here, behaving differently compared a subfigure, but is also used within a floating [...]
April 15, 2008 at 7:39 pm |
[...] have posted another article on that, just have a look there. minipage can also be used for text, not only for figures and [...]
May 8, 2008 at 6:21 pm |
Hi.
I’m trying to put a table and a picture side-by-side but my efforts are in vane.. who I can do that?
I made this but its not working well…
\begin{figure}[!h]
\subfloat{
\includegraphics[scale=0.5]{picture1}
}
\hspace{1.2cm}
\subfloat{
\begin{minipage}[t]{5cm}{5cm}
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{1}{|c|}{Sectores} & $[345;355[$ & $[355;5[$ \\
\multicolumn{1}{|c|}{Factores de calibração} & 1.02 & 1.02\\
\hline
\end{tabular}
\end{minipage}
}
\end{figure}
May 8, 2008 at 7:39 pm |
Hi Hugo,
There is indeed a problem in your code. Y only have one minipage for your tabular environment, but actually you need a minipage for the picture as well. So try this and let me know if you are still facing problems:
\begin{figure}[!h]
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics{picture1}
\end{minipage}
\hspace{1.2cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{1}{|c|}{Sectores} & $[345;355[$ & $[355;5[$ \\
\multicolumn{1}{|c|}{Factores de calibração} & 1.02 & 1.02\\
\hline
\end{tabular}
\end{minipage}
\end{figure}
Cheers,
Tom
July 29, 2008 at 2:48 am |
google xl2latex
August 6, 2008 at 5:30 am |
[...] from http://texblog.wordpress.com/2007/08/01/placing-figurestables-side-by-side-minipage/ [...]
November 12, 2008 at 7:17 am |
Hi
I am also trying to put a figure and a table side by side. They end up getting both Figure captions or table captions.
I am not able to give simultaneously different captions i.e. figure to figure and table to table.
Somebody please help.
Cheers
Amar
November 14, 2008 at 7:06 am |
Hi
I found the solution by modifying the help given in http://www.win.tue.nl/latex/documentation/plaatjes/pictures.pdf
\parbox [h]{0.4\textwidth}{
\includegraphics [width=\linewidth]{drawing.eps}
\captionof {figure}{caption1}
\label{fig:draw}
}
%\hfill
\hspace{0.5cm}
\parbox [h]{0.4\textwidth }{
\captionof {table}{caption2}
\begin{tabular}{|c|l|}
\hline
a & b
\hline
\end{tabular}
\label{tab:table1}
}
December 9, 2008 at 5:55 pm |
Laying out two tables of uneven length aligns both tables vertically in the middle. How would I align them both to the top?
I think that this is exactly the problem that Si was asking about?
December 10, 2008 at 10:12 pm |
Hi Albert,
I cannot reproduce what you are referring to. Can you please provide a minimal example? Might it be that your tables together are wider than the document’s “textwidth” and hence one is pushed to the next “line”?
Cheers,
Tom.
December 11, 2008 at 10:10 pm |
thanks!! That helped!!
December 26, 2008 at 2:59 pm |
[...] Using minipage environment. Here is an example. [...]
January 5, 2009 at 7:16 pm |
Thanks mate, fantastic blog! I’m adding you to my blog roll, if that’s ok…
May 18, 2009 at 10:40 am |
When i use the caption package, I got tons of errors after the place where I used the \captionof command… When I do not include the caption package, I only got 2 errors, there where I used the \captionof command…
anyone?
May 18, 2009 at 11:41 am |
My bad, found the problem. I had this error: “to many unprocessed floats”. By using the caption package, the size of some captions may be changed, and suddenly LaTeX placed all my figures at the end of the document. This happened with so many figures that LaTeX couldn’t put them down nicely on a page any more. By using the float package, I forced some figures in position, and problem solved.
An other solution when you got the error is putting in a \clearpage or \cleardoublepage command to allow a page full of figures to be generated.