2

I'm trying to prepare a calculus course and would like to have solutions (which usually don't take more than half of the width of the page, with a potential drawing on the right side.

My solutions are part of an "enumerate" environment", in which I use "align*" to have calculus steps made more clear.

I'm not finding any way to have a picture on the right side of each solution. Only thing I can think about is to have a "tabular", but the idea of combining "tabular", an "enumerate" in its left column that would be split over different lines, ... seems very complex to me.

Can you please help me get a simple solution with a clear layout for such a thing?

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,top=1.8cm,bottom=2cm,left=1.8cm,right=1.8cm]{geometry}
\usepackage[french]{babel}
\usepackage[dvipsnames,table]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % pour les caractères avec des accents
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\graphicspath{ {./images/} }

\begin{document}

\begin{enumerate}
    \item $cos (2x) = - cos (\pi - x)$
    \begin{align*}
     cos (2x) & = - cos (\pi - x)\\
     cos (2x) + cos (\pi - x) & = 0\\
     cos (2x) - cos(x) & = 0\\
     ...\\
    \end{align*}

\begin{figure}[h] % I'd like this picture to be on the right side of the first item
\begin{center}
\includegraphics[width=150pt]{example-image}
\end{center}
\end{figure}

    \item $sin(x)=-sin(\pi - 2x)$
\end{enumerate}

\end{document}

Link to example-image.pdf (I seem unable to attach a file that is not an image): https://drive.proton.me/urls/JQNA4TGEN8#2bueL70zHW1N

1
  • Could you please make your code complete and replace the picture with example-image.pdf?
    – Stephen
    Jan 1 at 13:08

1 Answer 1

2

I was able to get an MWE working with the minipage environment and the adjustbox package. The latter is for aligning the images, because aligning minipages can be finicky.

\documentclass[12pt, a4paper]{article}

\usepackage{geometry}
\usepackage{amsmath}
\usepackage[export]{adjustbox}  % For aligning images in minipages

\begin{document}

\begin{enumerate}
    \item
    \begin{minipage}[t]{0.45\textwidth}
        \(\cos(2x) = -\cos(\pi - x)\)
        \begin{align*}
            \cos(2x) &= -\cos(\pi - x)\\
            \cos(2x) + \cos(\pi - x) &= 0\\
            \cos(2x) - \cos(x) &= 0
        \end{align*}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.45\textwidth}
        \centering
        \includegraphics[width=0.8\textwidth, valign=t]{example-image-a}
    \end{minipage}

    \item
    \begin{minipage}[t]{0.45\textwidth}
        \(\sin(x) = -\sin(\pi - 2x)\)
    \end{minipage}
    \hfill
    \begin{minipage}[t]{0.45\textwidth}
        \centering
        \includegraphics[width=0.8\textwidth, valign=t]{example-image-b}
    \end{minipage}
\end{enumerate}

\end{document}

The [t] argument in the minipages aligns the minipages at the top based on the reference points of their contents. However, the reference point of an image is at its bottom-left corner, so this "top" alignment actually aligns the top of your text with the bottom of the image (as discussed here and here). As suggested by @egreg in this comment, the valign=t argument from the adjustbox package can force true top alignment.

MWE with example images aligned next to equations in an enumerate environment

You must log in to answer this question.

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