Placing figures/tables side-by-side (\minipage)

Including images in a report is very common in Latex. 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[width=\textwidth]{filename1}
\caption{default}
\label{fig:figure1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{filename2}
\caption{default}
\label{fig:figure2}
\end{minipage}
\end{figure}

Note, for certain figure manipulations such as width, loading the graphicx package is required:

\usepackage{graphicx}

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 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.


70 Responses to “Placing figures/tables side-by-side (\minipage)”

  • Donald

    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!

    • Danny

      You might want to have a look at LyX. I use it to create all my tables and then paste the generated code into my Latex document.
      :) .

    • Kevin

      I use a macro called calc2latex (converts tables form OpenOffice into latex output), works great! There’s one for Excel called xls2latex. Google them, follow the instructions and let the macros make the tables for you!

  • Creating two columns in article, report or book « Blog on Latex Matters

    [...] have posted another article on that, just have a look there. minipage can also be used for text, not only for figures and [...]

  • Placing figures/tables side-by-side (\subfigure) « Blog on Latex Matters

    [...] 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 [...]

  • Miguel Angel

    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

  • tom

    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

  • Miguel Angel

    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

  • tom

    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.

  • Amir

    I’m looking for a way to place a picture next to a table. Do you have any idea on this?

  • Amir

    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

  • Winkelwagen

    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.

  • ashokg

    i want side caption for figures in two column job and also bottom allignment

  • Aman

    Hey thanks … found your minipage stuff pretty useful

  • tom

    @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.

  • David

    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.

  • tom

    @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.

  • David

    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.

  • Teni

    Thanks, this article helped me a lot!

  • Kai

    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?

  • tom

    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

  • Si

    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

  • tom

    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.

  • Floating text around figure/table « Blog on Latex Matters

    [...] 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 [...]

  • Hugo

    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}

  • tom

    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

  • Amar Nath Satrawala

    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

  • Amar Nath Satrawala

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

  • Albert

    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?

    • tom

      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.

    • jpa

      Just for the record, aligning tables to top is possible by giving [t] to both minipage and the tabular:

      \begin{minipage}[t]{0.3\textwidth}
      \begin{tabular}[t]{ll}

  • Ketan

    thanks!! That helped!!

  • Spiros

    Thanks mate, fantastic blog! I’m adding you to my blog roll, if that’s ok…

  • Michiel

    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?

    • Michiel

      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.

  • MB

    When I try this, I get only one caption underneath both figures. I’ve tried all kinds of variations, but no luck.

  • Fran Freijedo

    Very nice help!! Fast and efficient!!

  • Sunil

    Hey Amir,
    It was really helpful for me!! After a long search on google for ‘image beside a table’, I finally ended up using your code. :)

    Thanks again.

  • Nasim

    Helped a lot! thanx guys! :-)

  • Bruhathi

    Hey thanks a lot. The idea helped

  • inUtil

    Worked perfectly for me with side by side pictures. Thanks for the tip!

  • Jesus

    Muchas Gracias
    Thank you so much

  • NIsha S Mehta

    Thanks a lot..!!

  • M

    Hi!! I wanted to put two figures side by side, and the minipage stuff works fine. However, it doesn’t look good at all. The figures are not placed at the exact same height and I can’t place the captions exactly under each figure (probably cause of the page size, which i do not want to change) Also, I can’t put the figures at the center of the page, they either go too left or too right no matter what i do…

  • M

    I can post the code if it helps undrestand what i mean..thanx!!

  • M

    Great! This is the code:
    \begin{figure}[H]
    \begin{minipage}[b]{0.4\textwidth}
    \begin{flushleft} \large
    \hspace{-100pt} \includegraphics[angle=270 , scale=0.3]{misdip3.jpeg}
    \caption[Evolution of the beta functions and the dispersion through FODO 3]
    {\textit{Evolution of the beta functions and the dispersion through FODO 3.}}
    \end{flushleft}
    \end{minipage}
    \hspace{60pt}
    \begin{minipage}[b]{0.4\textwidth}
    \begin{flushright} \large
    \includegraphics[angle=270 , scale=0.3]{misdip4.jpeg}
    \hspace{100pt}\caption[Evolution of the phase advance through FODO 3]%
    {\textit{Evolution of the phase advance through FODO 3.}}
    \end{flushright}
    \end{minipage}
    \end{figure}

    • tom

      Hi,
      What I propose is using the “subfigure” package instead of “minipage”, which gives you more flexibility. You can find a general introduction here.

      If you want more space between the figure and the caption, use:
      \usepackage[loose]{subfigure}

      Also, if you prefer numbers instead of the default numbering:
      \renewcommand{\thesubfigure}{\thefigure.\arabic{subfigure}}

      Here is a link to the documentation: subfigure

      Another thing that might be useful is the caption package (i.e. page 9). Among other things, it lets you define the font style of the caption and hence you don’t need to type the caption twice:

      \usepackage[textfont=it]{caption}

      Hope this works! Let me know if you have any other question.

      Cheers, Tom.

      ps.: This should do:
      \begin{figure}[h]
      \subfigure[Evolution of the beta functions and the dispersion through FODO 3]{
      \includegraphics[angle=270 , scale=0.3]{misdip3.jpeg}
      }
      \qquad % double quadspace
      \subfigure[Evolution of the phase advance through FODO 3.]{
      \includegraphics[angle=270 , scale=0.3]{misdip4.jpeg}
      }
      \end{figure}

  • karl

    Lifesaver! Thanks mate!

  • fofo

    Hi,
    I’m trying to put a table and a figure side by side using the minipage environment but I have this problem:
    the caption of the figure is considered as a table :(
    how to solve this ???
    regards

  • fofo

    Hi again,
    thanks, another way to solve it is to add the figure in the \begin{figure} environment :)
    Cheers.

  • christina

    hi Tom!
    i have to try make 2 lanscape table in 1 page. But the table can’t center,
    The top and bottom margin not same. How to solve this problem?could u?

    Cheers=)

    • tom

      Hi Christina,

      Do you want to rotate a single page and have two tables on that page in landscape format? If so, here is how you can achieve that:

      \usepackage{pdflscape}
      ...
      \begin{landscape}
      % Table 1
      %Table2
      \end{landscape}

      If this is not what you wanted, please provide code of a mini-example. Cheers, Tom.

  • Jorge

    Amir, your code worked wonderfully for me. I had been struggling with the format till I tried your solution.

    It turns out the issue was the [b] option after each \minipage command that made it look bad, ie, the table and the figure were placed side by side, but the figure was below the table. I removed that option and voilà, it worked.

    Thank you all!

  • sschmid

    Easiest solution (columns):

    \begin{columns}
    \begin{column}{0.5\textwidth}
    %text,figure..
    \end{column
    
    \begin{column}{0.5\textwidth}
    %...
    \end{column
    \end{columns}

    the rest all didn’t work for me (minipages, wrapfigure, parbox..), it kept aligning the elements top-down, if at all.

  • reju sam john

    thank you thank you very much

  • Using footnote in tables « LaTeX Matters

    [...] more appropriate solution would be using the minipage environment. Here is an [...]

  • sarvesh

    Dear Bob , I have 40 subfigure which i want to display with caption F1,F2, …F40 under single banner. I do not want to display figure numbering like (a) F1 (b) F2 (c) F3… etc instead of it i want to display F1 F2 F3 F4…etc
    please help me.
    Thanks

    regards
    sarvesh

    • tom

      Hi Sarvesh,

      Below is a minimal working example where subfloats have no label. For more information see my post, the subfig and caption package documentations. Best, Tom.

      \documentclass[11pt]{article}
      \usepackage{subfig, caption}
      \captionsetup[subfigure]{labelformat=empty}
      \begin{document}
      \begin{figure}[h]
      	\centering
      	\subfloat[][F1]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F2]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F3]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F4]{\rule{2.5cm}{2cm}}\\
      	\subfloat[][F5]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F6]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F7]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F8]{\rule{2.5cm}{2cm}}\\
      	\subfloat[][F9]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F10]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F11]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F12]{\rule{2.5cm}{2cm}}\\
      	\subfloat[][F13]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F14]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F15]{\rule{2.5cm}{2cm}}\quad
      	\subfloat[][F16]{\rule{2.5cm}{2cm}}
      \end{figure}
      \end{document}
  • steven

    My minipages are always stacked vertically. Any thoughts on why this is happening?

    • tom

      Hi Steven,

      In general, they are stacked vertically if there is not enough space to arrange them horizontally. For figures, try using the width option, e.g.:

      \usepackage{graphicx}
      ...
      \includegraphics[width=0.4\textwidth]{figure.file}

      If you provide a minimal working example, I may be able to help you better.

      Best, Tom.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 316 other followers