0

Bu using the default positioning of an image inserted with \includegraphics, from the graphicx package, an image following some text (not a new line) is aligned in such a way that it sticks out from the top, and the bottom of the text line is aligned with the image's bottom border, as you can see in the image below:

image aligned inconveniently

I would rather like the image to stick out from the bottom, in such a way that the top of the text line (in this case, "Question #2") be aligned with the top border of the image.

How do I achieve this effect using only the graphicx package and \includegraphics command, and nothing else, if possible? Excuse me for this imposed limitation. This is for homework, and I don't have the time to wrap my head around something like TikZ for now.

Here's a MWE, where I just stripped everything from my document but Question #2 and the command definitions and packages required to make it compile successfully (look at the line that starts with \includegraphics under the "body" header):

\documentclass{article}
\usepackage[letterpaper, top = 0.5in, bottom = 1in, left = 0.5in, right = 0.5in]{geometry}

% ===== for math =====
\usepackage{amsmath}
\usepackage{amssymb}
\newcommand{\mtangent}{m_\text{tangent}}
\newcommand{\msecant}{m_\text{secant}}
\newcommand{\Given}{\textbf{Given:}~}
\newcommand{\Required}{\textbf{Required:}~}
\newcommand{\Analysis}{\textbf{Analysis:}~}
\newcommand{\Solution}{\textbf{Solution:}~}
\newcommand{\Statement}{\textbf{Statement:}~}
\newcommand{\idem}{\emph{idem}}
\newcommand{\UNDEF}{\text{UNDEF}}
\newcommand{\DNE}{~\text{DNE}}

% ===== for question numbering =====
\usepackage{enumitem}

% ===== for graphics, including images and plots =====
\usepackage{graphicx}
\graphicspath{ {./images/} }

% ===== body =====
\begin{document}
 \begin{enumerate}[label=\textbf{Question \#\arabic*}, align=left, leftmargin=*]
  \refstepcounter{enumi}
  \item % Question #2
  \includegraphics[width=7cm]{question2.pdf}
  \begin{enumerate}[label=\textbf{(\alph*)}]\item{ % (a)
  \Given graph\\
  \Required \( \lim\limits_{x\to3^-}{f(x)} \)\\
  \Statement \( \lim\limits_{x\to3^-}{f(x)} = 1 \)
  }
  \item{ % (b)
  \Given\idem\\
  \Required \( \lim\limits_{x\to3^+}{f(x)} \)\\
  \Statement \( \lim\limits_{x\to3^+}{f(x)} = -2 \)
  }
  \item{ % (c)
  \Given\idem\\
  \Required \( \lim\limits_{x\to3}{f(x)} \)\\
  \Analysis\\
  \( \lim\limits_{x\to3^-}{f(x)}\neq\lim\limits_{x\to3^+}{f(x)} \)\\
  \( \therefore\lim\limits_{x\to3}{f(x)}\DNE \)\\
  \Statement\( \lim\limits_{x\to3}{f(x)}\DNE \)
  }\end{enumerate} % end alpha
 \end{enumerate} % end question numbering
 
\end{document}

Here's question2.pdf, for testing purposes.

6
  • Use \raisebox to move the picture down. Or use the adjustbox package. Feb 2, 2023 at 7:19
  • @UlrikeFischer Thanks for your comment! Can you show me a small sample of code so I can see how that \raisebox function works in my context? Thank you again.
    – GPWR
    Feb 2, 2023 at 12:49
  • sure, it you provide some small sample of code (a "Minimal Working Example", MWE) that I can use to insert and test my code. tex.meta.stackexchange.com/q/3343/2388 tex.meta.stackexchange.com/q/228 Feb 2, 2023 at 12:53
  • @UlrikeFischer Thank you for your comment. I edited my question to include a MWE.
    – GPWR
    Feb 3, 2023 at 17:06
  • I can't compile that as I don't have question2.pdf. Please test such a example in a new, empty folder to avoid to have local dependencies. Feb 3, 2023 at 17:14

1 Answer 1

2
\documentclass{article}
\usepackage{enumitem}
\usepackage{graphicx}
\begin{document}
 \begin{enumerate}[start=2,label=\textbf{Question \#\arabic*}, align=left, leftmargin=*]
  \item % Question #2
  \raisebox{\dimexpr-\height+\ht\strutbox}{\includegraphics[width=7cm]{example-image}}
  
  more text
 \end{enumerate} 
 
\end{document}
  

enter image description here

1
  • That solves it perfectly. I appreciate it greatly, and I wish you a great day. Thanks for your time.
    – GPWR
    Feb 3, 2023 at 17:58

You must log in to answer this question.

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