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.

I am trying to put a figure next to a list, where the list is talking about the figure. This is fine, I can do that with the minipage environment. However, my problem is that when I try to put a caption on the figure, it captions the entire "figure" containing the minipages, not just the picture itself. I have included an example of what I have done.

I have searched around on the internet but haven't been able to work out a solution. I have tried using subfigures, wrapping text, floatinf figure, etc. None of these have worked, often giving an output with the figure in the wrong place.

Any thoughts on how to fix this?

Here is my document so far:

\documentclass[twoside,a4paper]{report}
\usepackage[ignorefoot, ignoremp, ignorehead]{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{eepic}
\usepackage{mhchem}
\usepackage{chemstyle}
\usepackage{color}
\usepackage{./Scripts/simplemargins}
\usepackage{array}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{cite}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage{booktabs}
\usepackage{subfig}
\usepackage{hyperref}

\begin{document}

\begin{figure}[ht]
    \begin{minipage}[b]{0.48\linewidth}
        \begin{itemize} [ ] % To get list without points
            \item{Blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
            \item{More blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
        \end{itemize}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        \includegraphics[scale=0.2]{caption_example.pdf}
        \caption{default}
        \label{fig:label}
    \end{minipage}
\end{figure}

\end{document}

Example output

share|improve this question
    
Hi @anpro, welcome to tex.sx. Can you please add a full minimal example including the class and the packages you load? It works just fine with just article class and graphicx loaded. You seem to load some package which changes the caption (and itemize because the normal one doesn't like the [] argument). –  Martin Scharrer Feb 8 '11 at 8:40
    
@anpro: Could you include your preamble as well? I could not reproduce the issue with the documentclass article and the packages {enumitem} and [demo]{graphicx}. –  Jake Feb 8 '11 at 8:41
    
Hi. I added in my preamble, and also tried to put in an example output, but couldn't due to my rep not being high enough. I used the paralist package to alter the itemize environment. –  anpro Feb 8 '11 at 9:31
3  
@anpro: One way to fix this kind of things is to minimise the code, i.e. remove unrelated packages, text and macros, until the error disappears. Then the last thing removed most likely caused the issue. From that point it is much easier to troubleshoot, e.g. to have a peak in the manual of that package. –  Martin Scharrer Feb 8 '11 at 9:41
    
I just did that and it seems to be the chemstyle package that is causing the problems. –  anpro Feb 8 '11 at 9:49
show 3 more comments

3 Answers

up vote 2 down vote accepted

Use the chemstyle package with option floatrow (to make sure the floatrow package will be used by the chemstyle package) and put a \RawFloats as first command inside the figure:

\documentclass[twoside,a4paper]{report}
\usepackage[demo]{graphicx} % option "demo" added for compiling without images
\usepackage[floatrow]{chemstyle}
\usepackage{enumitem}

\begin{document}

\begin{figure}[ht]
\RawFloats
    \begin{minipage}[b]{0.48\linewidth}
        \begin{itemize} [ ] % To get list without points
            \item{Blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
            \item{More blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
        \end{itemize}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        \includegraphics[scale=0.2]{caption_example.pdf}
        \caption{default}
        \label{fig:label}
    \end{minipage}
\end{figure}

\end{document}

(The \RawFloats command is described in the floatrow package documentation.)

share|improve this answer
1  
@anpro: This is a much better way of fixing the problem (from the floatrow documentation: "If you want LATEX behavior just for one environment, input a \RawFloats command inside environment"). You should probably accept Axel's answer instead of mine. –  Jake Feb 8 '11 at 19:33
add comment

As Martin suggested in the comments, minimizing the code often helps (that's why it's called a minimal example :)

You've added two \usepackage{graphix} to your preamble, this seems too much. And to reproduce your problem, all the chemical packages seem too much too.

If I minimize your example, I don't see a problem with the code, as you can see in this screenshot.

\documentclass[twoside,a4paper]{report}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{enumitem}

\begin{document}
\lipsum[1]
\begin{figure}[ht]
    \begin{minipage}[b]{0.48\linewidth}
        \begin{itemize}[ ] % To get list without points
            \item{Blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
            \item{More blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
        \end{itemize}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.48\linewidth}
        \centering
        \includegraphics[scale=0.2]{caption_example.pdf}
        \caption{default}
        \label{fig:label}
    \end{minipage}
\end{figure}
\lipsum[1]
\end{document}

With your code I cannot seem to compile the document when I have \usepackage{chemstyle} turned on, so this might be the first package to look at.

Additionally I don't have access to %\usepackage{./Scripts/simplemargins}. Looking at the name, I suggest this simplemargins might be the culprit. Maybe it's doing something weird with the margin which influences the caption...

share|improve this answer
    
@anpro: Sorry, I didn't see your reply above while typing my answer. Glad Martins comment worked worked for you. –  Habi Feb 8 '11 at 10:28
add comment

One workaround for how the chemstyle package takes control of the caption placement is to not use a figure environment for the list and figure, and generate the caption using

\captionof{figure}{<caption>}

instead of

\caption{<caption>}

With this method, the construct will no longer float, which may or may not be acceptable for you.


Another way would be to use a subfloat with the subcaption redefined to look like a normal figure caption:

\documentclass[twoside,a4paper]{report}
\usepackage[ignorefoot, ignoremp, ignorehead]{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{eepic}
\usepackage{mhchem}
\usepackage{chemstyle}
\usepackage{color}
%\usepackage{./Scripts/simplemargins}
\usepackage{array}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{wrapfig}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{cite}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage{booktabs}
\usepackage{subfig}
\usepackage{hyperref}

\begin{document}
\captionsetup[subfigure]{font=normalsize,labelformat=simple}
\renewcommand{\thesubfigure}{Figure \arabic{figure}:}

\begin{figure}[ht]
    \begin{minipage}[b]{0.48\linewidth}
        \begin{itemize} [ ] % To get list without points
            \item{Blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
            \item{More blah blah blah
                \begin{enumerate}
                    \item{Text}
                    \item{Text}
                \end{enumerate}
            }
        \end{itemize}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.48\linewidth}
\subfloat[default]{
        \centering
        \includegraphics[scale=0.2]{caption_example.pdf}
        \label{fig:label}}
    \end{minipage}
\end{figure}

\end{document}
share|improve this answer
    
That worked great. Thanks for your help Jake. –  anpro Feb 8 '11 at 11:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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