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.45\linewidth} \centering \includegraphics[width=\textwidth]{filename1} \caption{default} \label{fig:figure1} \end{minipage} \hspace{0.5cm} \begin{minipage}[b]{0.45\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.45\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.45\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.
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!
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.
:).
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!
Here it is possible to import or to make your own tables http://www.tablesgenerator.com/
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 […]
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
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
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
You might want to try using the table itself to hold the note and source. Try this:
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:
It’s a lot more to type, but this way you can omit the vertical lines around the note and source.
I’m looking for a way to place a picture next to a table. Do you have any idea on this?
Ok, after some tries I could solve it myself. Here is the solution:
Thanks,
Amir
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.
i want side caption for figures in two column job and also bottom allignment
Hey thanks … found your minipage stuff pretty useful
@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:
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.
Hey
For some reason, I can’t get the minipage environment to place my tables side-by-side. Here’s the source:
Any ideas why this won’t work? Thanks.
@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
Tom.
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)
I then use this command in the table float as follows:
This works quite nicely.
Thanks, this article helped me a lot!
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?
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
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
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 […]
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…
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:
Cheers,
Tom
google xl2latex
Table , figure in twocolumn mode « Hla Hla Htay’s Notes
[…] from http://texblog.wordpress.com/2007/08/01/placing-figurestables-side-by-side-minipage/ […]
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
Hi
I found the solution by modifying the help given in http://www.win.tue.nl/latex/documentation/plaatjes/pictures.pdf
Hi,
the code didn’t work for me for placing a figure and a table near each other 🙁 is there any package (expect caption & graphicx) which should be added?
thanks in advance 🙂
Hello!
Please provide a minimal example. You may want to try the subfig package.
Best, Tom.
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?
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.
Just for the record, aligning tables to top is possible by giving [t] to both minipage and the tabular:
thanks!! That helped!!
Placing figures/tables side-by-side « Bekhongdeokinh’s Blog
[…] Using minipage environment. Here is an example. […]
Thanks mate, fantastic blog! I’m adding you to my blog roll, if that’s ok…
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?
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.
When I try this, I get only one caption underneath both figures. I’ve tried all kinds of variations, but no luck.
Very helpful. Thanks
Very nice help!! Fast and efficient!!
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.
Helped a lot! thanx guys! 🙂
Hey thanks a lot. The idea helped
Worked perfectly for me with side by side pictures. Thanks for the tip!
Muchas Gracias
Thank you so much
Thanks a lot..!!
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…
I can post the code if it helps undrestand what i mean..thanx!!
It would definitely be useful to have a minimal example to look at. Thanks, Tom.
Great! This is the code:
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:
Also, if you prefer numbers instead of the default numbering:
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:
Hope this works! Let me know if you have any other question.
Cheers, Tom.
ps.: This should do:
Lifesaver! Thanks mate!
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
Hi there!
Use
\figcaption{...}
instead of\caption{...}
, provided by the nonfloat package. You’ll have to load it in your preamble.Cheers, Tom.
Hi again,
thanks, another way to solve it is to add the figure in the \begin{figure} environment 🙂
Cheers.
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=)
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:
If this is not what you wanted, please provide code of a mini-example. Cheers, Tom.
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!
Easiest solution (columns):
the rest all didn’t work for me (minipages, wrapfigure, parbox..), it kept aligning the elements top-down, if at all.
thank you thank you very much
Using footnote in tables « LaTeX Matters
[…] more appropriate solution would be using the minipage environment. Here is an […]
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
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.
Thanks a lot Sir for helping me to get the desired output.
You are welcome. Cheers, Tom.
My minipages are always stacked vertically. Any thoughts on why this is happening?
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.:If you provide a minimal working example, I may be able to help you better.
Best, Tom.
Hi Tom,
I’m having a similar problem to Steven above. I’m using the code you provided to place mini pages horizontally, but they only stack vertically. Because of the cautionary note about the size of figures, I’ve attempted to remedy this by decreasing the image size and the buffer space between the images. Even though the figures are now only an inch across they still stack vertically. The code is as follows:
Any suggestions?
Thanks!
Hi Kevin,
The problem is not so much with the size of the figures inside the
minipage
environment, but the size of the minipage “box” itselves. Including the small horizontal space in-between, they are taking up more than the completelinewidth
. Try reducing their sizes slightly and it should work just fine.Example:
Cheers, Tom.
### Why am I not getting the images side-by-side?
Hi Tess,
Nice figures :-)! The space (line 23) ends the paragraph in LaTeX which is why the second figure is on the “next line” or below the first. Simply delete it and it should work. Also,
\hspace
is fine, however, LaTeX has standard space commands:\quad
and\qquad
. I recommend to use these. Finally, please provide a minimal working example including preamble next time, so I don’t have to figure out which packages and TikZ libraries you use.Thanks, Tom.
Thanks Tom ! It worked 🙂
Hi I want to align two conditional statements like we do using the \begin{split} command. In the following code, I want to align z3 and z4.
Hi Tess,
I assume by align, you mean vertically align
and
. Btw. you are loading several packages multiple times, including textcomp, float and amsmath. Not that it was wrong, but remember that sometimes the order makes a difference.
Cheers, Tom.
Thanks again Tom ! They are definitely getting aligned ! But I wanted them left aligned..that way they look better ! So, I used \begin{flalign*},
but that doesnot work ! Is there any other way to left align the conditional
equations?
In case you mean left in the document, you can pass the
fleqn
option to eitherdocumentclass
or theamsmath
package.or
To align the equations, this should work:
Hi all !
Why are my tikz figures not getting generated?
Hi!
Please only sent the code that is absolutely necessary to reproduce the issue. Including the LaTeX error would also be useful.
Could it be that your editor replaces double dash by a long dash? I had to replace the dashes on the lines highlighted below. Other than that, your tikz figure seems to be ok.
Cheers, Tom.
Thanks! This was helpful.
I only get one caption and it is only on the second picture?
Hi Michael,
Thanks for your comment. I’m not sure what you are doing exactly. But if you need captions for your figures, you might be better off using either subfigure or the more recent subfig package.
Nevertheless, here is a minimal example with two figures, each with a caption.
Best, Tom.
Hi, I am struggling with a captioning issue in minipage. The error I get states “Package floatrow Error: Caption(s) lost.” I have tried reading around this but cant find a solution to the issue. The code is one i have used previously and successfully so have no idea why it is now not working. Can anyone offer advice please?
General code used is as follows:
Many thanks in advance for any assistance given, greatly appreciated.
Hi Barry,
Your code works perfectly, the only problem was a “}” in the short caption of the second figure. The conflict is due to the floatrow package (as the error suggests). Remove it in case you don’t need it. Otherwise, I would need to see a minimal example which produces the error to be able to help.
Here is a complete minimal working example just using minipage including captions:
HI Tom,
Thank you very much for the prompt reply. I tried the altered code and still get the same error :(.
I have included the code proper below, I am just at a loss as to why it used to work fine and now doesnt. Beginning to wonder if I have a package conflict.
Thanks for the assistance once again
Again, the code works perfectly (apart from the missing graphicx package). You would need to give me an example that includes the packages you load, so I can reproduce the error. I.e., are you loading floatrow? Another possibility would be to use either subfigure or subfig. You might want to give those packages a try to see if it solves your problem.
Best, Tom.
Hi Tom,
Iam using this code to display images side by side. However I want to reduce the space between the displayed images even further(ideally < 2mm seperating every image) , so that I can increase the size of every image and still display in one row. At present the seperation is around ~1cm between two images with the below code. can you suggest how to do this using minipage ?
I suggest using
\hfill
, which basically fills whatever space is available. Here is your example with\hfill
:Best, Tom.
Hi Tom, first of all you have a great and very helpful blog. All of this information helped me place 2 figures side by side and a table and a firgure side by side (using the minipage command). I have 2 questions: One- Is it possible to place two figures side by side and immediately below them another two figures, all of these as one “unit”?
Two- It’s a bit hard to explain (I’d send you a pic but don’t know how), but as I’m making a table I’d like to know how to control the lines, e.g. I have three columns and above them one cell which is not divided by the lines of thecolumns below… Do you have any suggestions?
Thanks,
Roman
Hi Roman,
Thanks for your question. I’ll try to answer both below.
Question 1
Consider using the subfig package which I wrote about in this post. It’s more suitable for complex figures and supports captioning and referencing. Here is an example:
Question 2
The
tabular
environment knows multicolumn cells. This article explains how to do it with a basic example.Hope it helps!
Tom
Hey Tom, I’ve tried out your solution but then LaTeX informs me that this \usepackage[lofdepth]{subfig} package can’t work with \usepackage{subcaption}. I’m sorry I didn’t post what I’m using before:
Hi Roman,
The more recent
subcaption
package provides similar functionality tosubfig
. See the package documentation for more details. Here is the same example usingsubcaption
:Ok thanks and where do I put my pictures in the code? like I had to do before e.g. \includegraphics[width=\textwidth]{3sim1x1d1_30.jpg} 🙂
Hi Roman,
In my example, the
\rule
command is just a placeholder for the figure. So, all you have to do is replace them with your figures (\includegraphics
).Tom
Hey Tom thanks a lot it really helped, I’m relatively new at this so you helped me speed up my work 🙂
Happy to help :-)! Tom.
Dear All,
I have a problem that I cannot handle based on the forums I have read: using minipage, the [H] command does not work, the image disappears when I compile the source. Here is my code:
What should I do?
Thanks in advance.
Adam
Hi Adam,
Thanks for the code. Do you use
[H]
onminipage
? Try[H]
or[h!t]
on the figure.Please provide a complete minimal working example next time, including preamble.
Best, Tom.
Hi Tom,
thanks for the quick answer. I tried [H] and now [h!t] on the figure! Using [H], the figure disappears, using [h!t], the figure appears, but not on the defined area.
Adam
Hi Adam,
Glad it works! Hard to say why [H] doesn’t though. As I said, I’d need to see the code…
Cheers,
Tom
Hi Tom,
I try to do my best 🙂 However, I don’t know exactly what you need to help me.
I hope it is enough. Thank you for helping me.
Adam
Hi Adam,
Ideally, the code would illustrate your problem with as few lines as possible.
The problem is not related to eps-figures. You have two options:
Best, Tom
Hello Tom,
thank you for the fine explanation and the code.
Best wishes,
Adam
hey
i want to insert table and matrix in a line. plzz help me out. how to do dis??
Please post a minimal example of the table and matrix and I’ll be happy to advise how to place them side-by-side.
Cheers, Tom.
i want to insert a table and a figure side by side but when i do this the figures considered as atble and no of table increases.how can i do this??please help me
Hi Sunanda,
Take a look at the answer to a similar question on tex.SX. Please let me know if how it goes.
Best, Tom
here figure considered as a table.but why?
Thanks much for the code example. The figure is considered a table because the
caption
command is enclosed by atable
environment, which is independent of its content.HTH, Tom
Hi Tom
I required tex code for Table as well as figure both should be side by side in between paragraph of the same page.
Please see my code snippets section for more details.
If you are still stuck, please include a minimal working example and briefly describe what you tried and where you are facing problems.
Best, Tom