6

I inserted a graphic in an enumerated list and I am trying to make it as wide as the line width of the enumerated list. If I use the command width=\linewidth, width=\textwidth, or width=\columnwidth it makes it as wide as the line width of the document.

I have illustrated this by drawing red lines on the screenshot of my output.

I would really appreciate any help. Thank you in advance!


Here is the code:

\documentclass[letterpaper, 10pt, draft]{article}

\usepackage{graphicx}
\usepackage{float}

% CREATING MY CODE ENVIRONMENT
    \usepackage{xcolor}
    \definecolor{codegray}{gray}{0.9}
    \newcommand{\code}[2][black]{\textcolor{#1}{\colorbox{codegray}{\texttt{#2}}}}


\begin{document}

In case the user needs to create a new indexing profile, he or she should do the following.

\begin{enumerate}
    \item In the \code{Setup Indexed Job Parameters} prompt shown in Figure \ref{fig:IndexSetup}, click on \code{Manage profiles}.
    \item \code{Manage Indexing Profiles} prompt shown in Figure \ref{fig:manage-profiles} will pop up. Enter the name for the profile, and click \code{OK}.
        \begin{figure}[H]
            \centering
            \includegraphics[width=\linewidth]{X.png}
            \caption{Manage Indexing Profiles Prompt}
            \label{fig:manage-profiles}
        \end{figure}
\end{enumerate}
        
\end{document}  

Here is the (annotated) output:enter image description here

1

2 Answers 2

5

Use a minipage instead of a figure environment...

Figure is supposed to float and doesn't take care of your \linewidth but of the global \linewidth instead.

\documentclass[letterpaper, 10pt, draft]{article}

\usepackage{graphicx}
\usepackage{float}
\usepackage{capt-of}
% CREATING MY CODE ENVIRONMENT
    \usepackage{xcolor}
    \definecolor{codegray}{gray}{0.9}
    \newcommand{\code}[2][black]{\textcolor{#1}{\colorbox{codegray}{\texttt{#2}}}}


\begin{document}

In case the user needs to create a new indexing profile, he or she should do the following.

\begin{enumerate}
    \item In the \code{Setup Indexed Job Parameters} prompt shown in Figure \ref{fig:IndexSetup}, click on \code{Manage profiles}.
    \item \code{Manage Indexing Profiles} prompt shown in Figure \ref{fig:manage-profiles} will pop up. Enter the name for the profile, and click \code{OK}.\\
        \begin{minipage}{\linewidth}
            \centering
            \includegraphics[width=\linewidth]{example-image-a}
            \captionof{figure}{Manage Indexing Profiles Prompt}
            \label{fig:manage-profiles}
        \end{minipage}
\end{enumerate}
        
\end{document}
4

Remove the figureenvironment, nest your image in a \parbox{\linewidth}, and use \captionof{figure}:

\documentclass[letterpaper, 10pt]{article}%
\usepackage[showframe]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}

% CREATING MY CODE ENVIRONMENT
    \usepackage{xcolor}
    \definecolor{codegray}{gray}{0.9}
    \newcommand{\code}[2][black]{\textcolor{#1}{\colorbox{codegray}{\texttt{#2}}}}

\begin{document}

In case the user needs to create a new indexing profile, he or she should do the following.

\begin{enumerate}
    \item In the \code{Setup Indexed Job Parameters} prompt shown in Figure \ref{fig:IndexSetup}, click on \code{Manage profiles}.
    \item \code{Manage Indexing Profiles} prompt shown in Figure \ref{fig:manage-profiles} will pop up. Enter the name for the profile, and click \code{OK}.\medskip\\
\parbox{\linewidth}%
        {\centering%
            \includegraphics[width=\linewidth]{venus-mars-and-cupid}
            \captionof{figure}{Manage Indexing Profiles Prompt}
            \label{fig:manage-profiles}
        }
\end{enumerate}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .