Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

How can I put two figures side-by-side? Not two sub-figures, but two actual figures with separate "Fig.: bla bla" captions. A figure is supposed to spread over the entire text width, but I have two figures which are narrow and long, and I need to save the space in order to withstand the pages limit.

share|improve this question

marked as duplicate by Svend Tveskæg, Peter Jansson, Heiko Oberdiek, ChrisS, Guido Feb 16 at 22:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

4 Answers

up vote 26 down vote accepted

Have you tried putting each of them in a minipage environment? They won't float at all, but you can make sure they appear side-by-side.

Edit: This isn't as straightforward as I thought. You can't put a figure environment inside a minipage environment. You get a "not in outer par mode" error.

But as Stefan notes, you can put minipages inside a figure environment and get separate captions!

\documentclass{article}

\usepackage{lipsum}

\newcommand{\exedout}{%
  \rule{0.8\textwidth}{0.5\textwidth}%
}

\begin{document}
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\centering
\begin{minipage}{0.45\textwidth}
\centering
\exedout % first figure itself
\caption{first figure}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\centering
\exedout % second figure itself
\caption{second figure}
\end{minipage}
\end{figure}

\lipsum

\end{document}

I was surprised to discover two \captions in the same figure environment actually work as desired.

HT: LaTeX Matters via Google

share|improve this answer
1  
This is what I ended up with. It appears that the actual semantics of figure is: "Everything with a caption in this environment is a figure, and it all floats together". –  Little Bobby Tables Nov 23 '10 at 9:09
2  
I normally put a \hfill between the minipages to spread them evenly over the text width. –  Martin Scharrer Apr 28 '11 at 17:49
    
This worked nicely, but then I wanted another line of pictures underneath. Is that possible somehow? –  Thomas Ahle Sep 19 '13 at 18:31
add comment

Since your figures shall be side by side, they are not expected to float independently. So you need just one figure environment for both objects.

Within this figure environment, you may use minipages (like Matthew already suggested). Some additions:

  • minipages understand optional alignment parameters to align at top, bottom or center.
  • For adding a caption to the minipages, I recommend to use the subcaption package. It is part of the feature-rich caption package.

Nevertheless you could check out the subfig package. That task could be handled like subfigures even if you customize the captions such that they look like two independent figures.

share|improve this answer
add comment

The floatrowpackage can easily do that (and many other things) with its floatrow environment:

       \documentclass[12pt,a4paper]{article}
        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{lmodern}
        \usepackage{graphicx}
        \usepackage{caption}
         \usepackage{floatrow}%

        \begin{document}

        \begin{figure}[!h]
           \begin{floatrow}
             \ffigbox{\includegraphics[scale = 0.8]{casxinf1}}{\caption{Case  $ x  < 1 $}\label{case1}}
             \ffigbox{\includegraphics[scale = 0.8]{zoom}}{\caption{A zoom}\label{zoom}}
           \end{floatrow}
        \end{figure}

        \end{document}

enter image description here

share|improve this answer
add comment

I got this working in a document with two text columns, just wanted to share what I did.

In this case, I wanted one figure of two side-by-side images to appear within one text column.

The \centering inside the minipages caused trouble so I removed them. Moreover, \linewidth (one-column width) needs to be used rather than \textwidth (which equals the full two-column width).

Another pitfall is the width= parameter of the \includegraphics: Since we're within a minipage, this width refers to the width of the minipage, not the width of the column.

Here's my code:

\begin{figure}
\centering
\begin{minipage}{.45\linewidth}
  \includegraphics[width=\linewidth]{img1.png}
  \captionof{figure}{First caption}
  \label{img1}
\end{minipage}
\hspace{.05\linewidth}
\begin{minipage}{.45\linewidth}
  \includegraphics[width=\linewidth]{img2.png}
  \captionof{figure}{Second caption}
  \label{img2}
\end{minipage}
\end{figure}

The \hspace{.05\linewidth} makes sure there is some horizontal space between the two captions.

share|improve this answer
    
Since you're already operating in a figure environment, what is the advantage of using \captionof{figure}{...} instead of the simpler \figure{...}? Second, I'm confused by your write-up: you state that you're looking to have two figures within one column -- presumably one above the other, right? -- yet the code you post would place them side-by-side. Third, please don't post just code snippets, but compilable examples that start with \document{<some class>} and end with \end{document}. –  Mico Feb 16 at 16:27
    
@mico I tried replacing with \figure{...}, but that gives me a "Caption(s) lost" error. I do wish side-by-side images, but within one text column, e.i., not spanning both text colums. I've clarified that now, it was mis-leading before, thanks for pointing it out. –  Carl Feb 16 at 17:26
    
I don't get the error message about "Caption(s) lost" when replacing \captionof with \caption. I expanded your code snippet into an MWE by loading the graphicx and caption packages; are you maybe loading additional packages that could create some interference? –  Mico Feb 16 at 18:01
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.