2

When i use a figure alone (and nothing more) in an itemize environment as in the sample code

\item[11.7]

\begin{center}
\includegraphics [width=9cm]{code-page629.eps}
\end{center}

the numbering (11.7 in this case) is printed in the bottom left corner. Is it possible to print the numbering in the top left corner? (see the attached figure). I do not provide a MWE since there is no need to run something, it is actually a "theoretical" question .. thanks a lot !enter image description here

  • Add \usepackage[export]{adjustbox} to the preamble and valign=t into the optional argument of \includegraphics. – leandriis 13 hours ago
  • 1
    Depending on the overall purpose of this, there is most likely a better way to achive the desired output. e.g. the center environment doe not only center the image but also changes the horizontal position of the number. Lastly, the combination of an itemize environment with a manually numbered item seems a bit strage. – leandriis 13 hours ago
  • How is it a theoretical question if you have existing code and an image? Regardless, even if the question were truly theoretical, providing a MWE would give everyone something to start with. – Teepeemm 8 hours ago
2

A quick fix that simply corrects this is to place an invisible character \strut after the item:

screenshot

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\begin{document}
   \begin{enumerate}
   \item Premier
   \item Second
   \item[11.7]\strut
      \begin{center}
      \includegraphics [width=9cm]{example-image}
      \end{center}
   \end{enumerate}
\end{document}
| improve this answer | |
  • 1
    Yes, it worked and this is exactly what I want .. thanks a lot ! – Athanasios Margaris 11 hours ago
2

Without adjustbox:

\documentclass[a5paper,twocolumn]{article}
\usepackage{graphicx}
\def\itemimg#1#2{\item[#1]\leavevmode\vskip-\baselineskip\includegraphics[width=\linewidth]{#2}}
\begin{document}
\begin{itemize}
\itemimg{11.7}{example-image-a}
\itemimg{11.8}{example-image-b}
\end{itemize}
\end{document}

BTW, If all the images are like simple tables, consider type the tables directly, that is:

\begin{tabular}{lllll}
    11.7 & YY & EQU & ... & ...  \\
         & SAVEX & EQU & ... & ...  \\ 
\end{tabular}
| improve this answer | |
1

I have no idea, why you would want to do this and there are definitely better ways to do this, but what you need to know is that the referencepoint of an image in Tex is always the lower left corner. So what you need to do is wrap your picture in a box to get the reference into the upper left corner.

\usepackage{adjustbox} should be the way to go. look up the vertical alignment.

here ist an example, which also centers it:

\documentclass{article}
\usepackage{adjustbox}
\begin{document}

\begin{itemize}
\item[11.7] \adjustbox{width=9cm,center,valign=t}{\includegraphics{code-page629.eps}}
\end{itemize}

\end{document}
| improve this answer | |
New contributor
Cube is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    you might also want to take a look at the Listing package, if your representing code snippets in your document – Cube 12 hours ago
  • 2
    If you use \usepackage[export]{adjustbox} you can directly add the valign option to the \includegraphics command as follows: \includegraphics [width=9cm, valign=t]{code-page629.eps} – leandriis 12 hours ago

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.