1

When I try to place an image within a figure environment within an enumerate environment and set the image's width to linewidth the image ends up being as wide as the text surrounding the enumerate rather than as wide as the enumerate environment itself, as shown below.

enter image description here

The right-hand margin of the image is in the correct position, but I want the left-hand margin to be lined up with the lines that begin 'Nullam', 'non', 'dapibus'.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ex odio, tempus vitae tempus sed, molestie eu velit. Donec venenatis dui arcu, a malesuada eros consequat quis.
\begin{enumerate}
    \item Nullam volutpat et libero commodo feugiat. Donec accumsan odio justo, non tempus metus rhoncus vel. Nulla fermentum interdum ipsum, sed dapibus tellus lacinia in.
    \begin{figure} [h]
        \includegraphics[width=\linewidth]{sled-dogs}
        \caption{Sled Dogs}
    \end{figure}
Donec pretium lorem non turpis laoreet, a tristique magna laoreet. Morbi est nibh, mollis quis fermentum a, cursus quis augue. Donec ac sodales neque. Duis blandit eleifend velit, quis scelerisque quam finibus sed. Nulla vehicula ipsum id nunc vulputate cursus.
\end{enumerate}
Vestibulum placerat tempus felis ac condimentum. Nam mauris eros, tincidunt vitae elementum eget, tempus vitae justo. Duis gravida lacus sed risus tristique commodo.
\end{document}
3

A figure is a floating enviornment which may be set at a place different from its position in the source it would look very odd if a figure was set to a narrow width as the source happened to be in a list some pages earlier.

By design it isolates itself from the settings at the current point. line width and fonts and some spacing settings are all normalised to document defaults.

Note that you should never use [h] as if the figure does not fit at the current point highly likely with a large image unless the current point happens to fall near the top of a page, as it means not top or not on a float page, which means that it may not be placed anywhere. Early versions of LaTeX would do exactly that and hold the [h] float to the end of the document. In LaTeX2e the system assumes you did not mean what you specified and issues a warning that [h] is being changed to [ht] which allows the float to be put at the top of the next page if necessary.

If the image is an intrinsic part of the list then it should not be a float so instead of figure just use

\begin{center}
\includegraphics[width=\linewidth]{..}
\end{center}

and the current list item line length will be used.

1

Replace the figure+captionenvironment withcenter+\captionof`, and it works:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx, caption}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ex odio, tempus vitae tempus sed, molestie eu velit. Donec venenatis dui arcu, a malesuada eros consequat quis.
\begin{enumerate}
    \item Nullam volutpat et libero commodo feugiat. Donec accumsan odio justo, non tempus metus rhoncus vel. Nulla fermentum interdum ipsum, sed dapibus tellus lacinia in.
    \begin{center}
       \includegraphics[width=0.5\linewidth]{lepursuit1}\includegraphics[width=0.5\linewidth]{penelope}
        \captionof{figure}{Le Pursuit}
    \end{center}
Donec pretium lorem non turpis laoreet, a tristique magna laoreet. Morbi est nibh, mollis quis fermentum a, cursus quis augue. Donec ac sodales neque. Duis blandit eleifend velit, quis scelerisque quam finibus sed. Nulla vehicula ipsum id nunc vulputate cursus.
\end{enumerate}
Vestibulum placerat tempus felis ac condimentum. Nam mauris eros, tincidunt vitae elementum eget, tempus vitae justo. Duis gravida lacus sed risus tristique commodo.
\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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