如何在「枚舉」環境中將影像放置在微積分的右側?

如何在「枚舉」環境中將影像放置在微積分的右側?

我正在嘗試準備微積分課程,並希望找到解決方案(通常不會佔用超過頁面寬度的一半,並且可能在右側繪製圖形。

我的解決方案是“枚舉”環境的一部分”,其中我使用“align*”使微積分步驟更加清晰。

我沒有找到任何方法可以在每個解決方案的右側顯示圖片。我唯一能想到的就是擁有一個“表格”,但是組合“表格”的想法,即左列中的“枚舉”,將被分成不同的行,......對我來說似乎非常複雜。

您能幫我找到一個佈局清晰的簡單解決方案嗎?

\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}

連結到 example-image.pdf (我似乎無法附加非圖像文件):https://drive.proton.me/urls/JQNA4TGEN8#2bueL70zHW1N

答案1

我能夠讓 MWE 與minipage環境和adjustbox套件一起工作。後者用於對齊圖像,因為對齊小型頁面可能很挑剔。

\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}

[t]根據其內容的參考點在頂部對齊迷你頁。但是,圖像的參考點位於其左下角,因此這種「頂部」對齊實際上將文字的頂部與圖像的底部對齊(如所討論的)這裡這裡)。正如 @egreg 所建議的這則評論,包valign=t中的參數adjustbox可以強制真正的頂部對齊。

MWE,其中範例影像在枚舉環境中與方程式對齊

相關內容