使用 wrapfig 和 enumerate 格式化 circuitikz 时出现问题

使用 wrapfig 和 enumerate 格式化 circuitikz 时出现问题

我正在尝试格式化一个基本电路问题,其中电路图放在多项选择题中的选项右侧。

目前看来,

格式错误的多项选择题

我追求的是类似的东西,例如

格式正确的多项选择题

不幸的是,我无法弄清楚如何使用 wrapfigure 和 enumerate 环境来做到这一点。电路图被放置在选项下方,而不是右侧。任何帮助都将不胜感激!

\documentclass{exam}

\usepackage{circuitikz} % for drawing circuit diagrams
\usepackage{wrapfig} % for wrapfigure environment
\usepackage{enumitem} % more options for enumerate command

% define enumerate command for new multiple choice question
\newlist{mcquestion}{enumerate}{1}
\setlist[mcquestion,1]{label={\bfseries\arabic{mcquestioni}.}, leftmargin=*, resume=mcquestion}
\def\remembered[#1]{\typeout{Call #1:\arabic{mcquestioni}}}

% define enumerate command for possible choices
\newlist{mchoices}{enumerate}{1}
\setlist[mchoices,1]{label={\bfseries\alph*.}, wide=1cm, leftmargin=*}

\begin{document}

\begin{mcquestion}
    \item In the circuit drawn in the figure, the ammeter has no resistance, and the battery has an e.m.f.~$\varepsilon$ and an internal resistance~$r$. Which of the following is correct?
\end{mcquestion}

\begin{mchoices}
    \item The current flowing through the ammeter is zero.
    \item The p.d. across the ammeter is zero.
    \item The potential drop \textbf{inside} the battery is zero.
    \item The energy dissipated in the whole circuit is zero.
\end{mchoices}

\begin{wrapfigure}{R}{0.5\linewidth}
\begin{circuitikz}[scale=2] \draw
    (0,1)   to[battery, l={$\varepsilon$, r}]   (1,1)
    (1,1)   --                                  (1,0)
    (1,0)   to[rmeter, t=A]                     (0,0)
    (0,0)   --                                  (0,1)
;
\end{circuitikz}
\end{wrapfigure}

\end{document}

答案1

正如我所评论的,wrapfig列表环境不能很好地协同工作,如手册(第一页)所述:

在此处输入图片描述

虽然你可以帮助它发挥作用,我认为在这种情况下,明确使用 minipage 更好(我将problem未定义的 更改为mquestion):

\documentclass{exam}

\usepackage{circuitikz} % for drawing circuit diagrams
\usepackage{wrapfig} % for wrapfigure environment
\usepackage{enumitem} % more options for enumerate command

% define enumerate command for new multiple choice question
\newlist{mquestion}{enumerate}{1}
\setlist[mquestion,1]{label={\bfseries\arabic{mquestioni}.}, leftmargin=*, resume=mquestion}
\def\remembered[#1]{\typeout{Call #1:\arabic{mquestioni}}}

% define enumerate command for possible choices
\newlist{mchoices}{enumerate}{1}
\setlist[mchoices,1]{label={\bfseries\alph*.}, wide=1cm, leftmargin=*}

\begin{document}

\begin{mquestion}
    \item In the circuit drawn in the figure, the ammeter has no resistance, and the battery has an e.m.f.~$\varepsilon$ and an internal resistance~$r$. Which of the following is correct?
\end{mquestion}

\begin{minipage}[t]{0.65\linewidth}
\begin{mchoices}
    \item The current flowing through the ammeter is zero.
    \item The p.d. across the ammeter is zero.
    \item The potential drop \textbf{inside} the battery is zero.
    \item The energy dissipated in the whole circuit is zero.
\end{mchoices}
\end{minipage}\begin{minipage}[t]{0.3\linewidth}
\begin{circuitikz}[scale=2, baseline=(A.center)] \draw
    (0,1)   to[battery, l={$\varepsilon$, r}, name=A]   (1,1)
    (1,1)   --                                  (1,0)
    (1,0)   to[rmeter, t=A]                     (0,0)
    (0,0)   --                                  (0,1)
;
\end{circuitikz}
\end{minipage}
\end{document}

在此处输入图片描述

注意我如何使用选项微调电路的垂直位置baseline(这是来自 TiZ)。

相关内容