3

I am trying to post an image inside an enumerated list but the left margin it starts with is the indented margin from enumerate. Is there any way to ignore that without having to break the enumerate? Here is what I have:

% Part (a)
\item A single plot showing the temporal change of the "High" and "Low" attributes\\\\
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{HW2_2a.png}

and the output is:

enter image description here

As you can see its being pushed to far to the right and just looks weird

Zarko
  • 296,517
  • Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Apr 14 '16 at 09:57

2 Answers2

2

You have two possibilities:

  • discontinue itemize for inserting image
  • define new environment, which will do this just for image.

In second case try:

\documentclass{article}
\usepackage{changepage}
\makeatletter
\newenvironment{restoretext}%
    {\@parboxrestore%
     \begin{adjustwidth}{}{\leftmargin}%
    }{\end{adjustwidth}
     }
\makeatother

\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{showframe}
\makeatother

\begin{document}
\lipsum[2]
    \begin{itemize}
\item   \lipsum[2]
    \begin{restoretext}
\includegraphics[width=\textwidth,height=1cm]{example-image}
    \end{restoretext}
\item   \lipsum[2]
    \end{itemize}
\end{document}

enter image description here

Zarko
  • 296,517
0

Another option is to use \linewidth instead of \textwdith which has the advantage that it is clear that the image is part of the current item.

enter image description here

References:

Code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{showframe}
%\usepackage{enumitem}

\begin{document} \lipsum[2] \begin{itemize} \item \lipsum[2]

\includegraphics[width=\linewidth,height=2cm]{../images/EiffelWide}

\item   \lipsum[2]

\end{itemize} \end{document}

Peter Grill
  • 223,288