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'm trying to put an image with a caption on it within an itemize environment (within another itemize environment). When I had the image with no caption, simply using \includegraphics, it indented to the same level as the other elements of the itemize list. However, when I wrapped it in a figure environment because I wanted a caption, it is indented to the left margin, completely sticking out of the list.

Here's what I've got:

\begin{itemize}
    \item Describing large-scale processor activity.

    \item To discuss digital systems of this scale and level of complexity
    we need a number of descriptive tools.

    \item For example:                                                 

    \begin{itemize}
        \item[a)] Circuit schematics highlight the circuit components and
        their connectivity.

        \begin{figure}[h]

            \includegraphics[width=10cm{assets/fig001.png}
            \caption{Transfer from R1 to R2 whenK1=1}
        \end{figure}
        \item[b)] Timing diagrams highlight the detailed time sequence of
        transfer between registers

        \includegraphics[width=10cm]{assets/fig002.png}

    \end{itemize}
\end{itemize}

Here's the result:

enter image description here

I've tried h, h! and H in the figure positioning, but it stays exactly where it is.

TL;DR: How can I have the first image here indented like the second, but with a caption?

share|improve this question

1 Answer 1

up vote 11 down vote accepted

Don't use a floating environment (such as figure) if you want your image to appear in the exact position where you write it. You can use a minipage and, if a caption is required, the \captionof command (provided by the capt-of package or by the caption package).

In the following example I illustrate this approach; I also used the `enumitem package to customize the labels for the inner list:

\documentclass{article}
\usepackage[demo]{graphicx}% demo option just for the example
\usepackage{caption}
\usepackage{enumitem}
\begin{document}

\begin{itemize}
    \item Describing large-scale processor activity.
    \item To discuss digital systems of this scale and level of complexity
    we need a number of descriptive tools.
    \item For example:                                                 
    \begin{enumerate}[label=\alph*)]
        \item Circuit schematics highlight the circuit components and
        their connectivity.\par
        \begin{minipage}{\linewidth}
            \centering
            \includegraphics[width=10cm]{assets/fig001.png}
            \captionof{figure}{Transfer from R1 to R2 whenK1=1}
        \end{minipage}
        \item Timing diagrams highlight the detailed time sequence of
        transfer between registers.\par
        \includegraphics[width=10cm]{assets/fig002.png}
    \end{enumerate}
\end{itemize}

\end{document}

enter image description here

share|improve this answer
    
That looks perfect, thanks –  luigii May 5 '12 at 2:55

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.