在下面的 mwe 中,我希望将圆欧姆公式图形放置在更靠右的位置,图形底部与问题 4 的选项 D 对齐。我不想要问题之间的空白。在\includegraphics
列表环境之外和之内移动命令也会产生奇怪的效果。
我试过了
\newlength{\oldparindent} \setlength{\oldparindent}{\parindent}% Save \parindent
\setbox0=\hbox{\includegraphics[width=0.17\textwidth]{ohm_law}}% Original image
\noindent\begin{minipage}[t]{0.6\textwidth}
\end{minipage}\hfill
\begin{minipage}[t]{0.17\textwidth}
\raisebox{-\ht0}{\usebox0}% Insert image
\end{minipage}
这是我在某个地方找到的。它将图形移到右侧,将问题分开,在左侧留出空白。我相信解决方案是 minipage,但如何解决呢?
以下是 mwe:
\documentclass[12pt,letterpaper,addpoints]{exam}
\usepackage{geometry}
\usepackage{float}
%\usepackage[scaled=1.05,proportional,lightcondensed]{zlmtt}
\usepackage{graphicx} %needed to include pictures (png)
\usepackage{tabularx}%\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{inconsolata}
\renewcommand*\familydefault{\ttdefault} %% Only if the base font of the document is to be typewriter style
\extraheadheight[-1.25in]{-0.25in}
\extrafootheight{-1in}
\begin{document}
%\printanswers %uncomment and re-compile to print answer key
\pagestyle{headandfoot}
\runningheadrule
\lhead{}
\chead[]{Electrical Systems 20 Exam(continued)}
\rhead{}
\title{Electrical Systems 20 \\\textsc{Exam}}
\date{}
\maketitle
\textsc{NAME}\enspace\makebox[3in]{\hrulefill}
\textsc{DATE}\enspace\makebox[1.5in]{\hrulefill}
\fullwidth{}
\vspace{0.1in}
%\fullwidth{\large \textbf{1) Multiple Choices}}
\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
\textsc {Choose the \emph{most correct} answer from the choices given.}}}}
\end{center}
\vspace{0.1in}
\begin{questions}
\boxedpoints
\pointsinrightmargin
\question[1]Automotive wiring diagrams include
\begin{choices}
\choice A series of colour coded diagrams
\choice Specific symbols to identify components
\choice Wire gauge sizes
\correctchoice All of the above
\end{choices}
\question[1]When soldering an electrical connection, use
\begin{choices}
\choice Acid core flux
\correctchoice Rosin core flux
\choice A or B
\choice Neither A or B
\end{choices}
\question[1]An electrical component that allows current to flow in one
direction only is called
\begin{choices}
\choice Watt
\choice Anode
\choice Cathode
\CorrectChoice Diode
\end{choices}
\question[1]Ohm's law states that
\includegraphics[width=2.0cm]{ohm_law} %started with this
\begin{choices}
\choice $1\ volt = 1\ amp \times 1 \Omega$
\choice $1\ amp = \frac{1\ volt}{1 \Omega}$
\choice $1 \Omega = \frac{1\ volt}{1\ amp}$
\CorrectChoice All of the above are true.
\end{choices}
\question[1] In a parallel circuit,
\begin{choices}
\choice the voltage is the same throughout the circuit, but the
current is divided.
\choice The total circuit resistance is always less than the smallest
resistor in the circuit.
\choice there is more than one path for current to flow.
\CorrectChoice All of the above are true.
\end{choices}
\question[1] An electronic device which acts like a high speed switch
is a
\begin{choices}
\choice triode
\choice diode
\choice monode
\correctchoice transistor
\end{choices}
\end{questions}
\end{document} here
答案1
您可以定义如下宏:
\newcommand\myimage[2][width=2cm]{%
\hfill\makebox[0pt][r]{\raisebox{-\height}[0pt][0pt]{\includegraphics[#1]{#2}}}
}
并像使用它一样
\question[1]Ohm's law states that\myimage[width=3cm]{example-image}
\begin{choices}
\choice $1\ volt = 1\ amp \times 1 \Omega$
\choice $1\ amp = \frac{1\ volt}{1 \Omega}$
\choice $1 \Omega = \frac{1\ volt}{1\ amp}$
\CorrectChoice All of the above are true.
\end{choices}
完整代码:
\documentclass[12pt,letterpaper,addpoints]{exam}
\usepackage{geometry}
\usepackage{float}
%\usepackage[scaled=1.05,proportional,lightcondensed]{zlmtt}
\usepackage{graphicx} %needed to include pictures (png)
\usepackage{tabularx}%\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{inconsolata}
\renewcommand*\familydefault{\ttdefault} %% Only if the base font of the document is to be typewriter style
\extraheadheight[-1.25in]{-0.25in}
\extrafootheight{-1in}
\newcommand\myimage[2][width=2cm]{%
\hfill\makebox[0pt][r]{\raisebox{-\height}[0pt][0pt]{\includegraphics[#1]{#2}}}
}
\begin{document}
%\printanswers %uncomment and re-compile to print answer key
\pagestyle{headandfoot}
\runningheadrule
\lhead{}
\chead[]{Electrical Systems 20 Exam(continued)}
\rhead{}
\title{Electrical Systems 20 \\\textsc{Exam}}
\date{}
\maketitle
\textsc{NAME}\enspace\makebox[3in]{\hrulefill}
\textsc{DATE}\enspace\makebox[1.5in]{\hrulefill}
\fullwidth{}
\vspace{0.1in}
%\fullwidth{\large \textbf{1) Multiple Choices}}
\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
\textsc {Choose the \emph{most correct} answer from the choices given.}}}}
\end{center}
\vspace{0.1in}
\begin{questions}
\boxedpoints
\pointsinrightmargin
\question[1]Automotive wiring diagrams include
\begin{choices}
\choice A series of colour coded diagrams
\choice Specific symbols to identify components
\choice Wire gauge sizes
\correctchoice All of the above
\end{choices}
\question[1]When soldering an electrical connection, use
\begin{choices}
\choice Acid core flux
\correctchoice Rosin core flux
\choice A or B
\choice Neither A or B
\end{choices}
\question[1]An electrical component that allows current to flow in one
direction only is called
\begin{choices}
\choice Watt
\choice Anode
\choice Cathode
\CorrectChoice Diode
\end{choices}
\question[1]Ohm's law states that\myimage[width=3cm]{example-image}
%\hfill\makebox[0pt][r]{\raisebox{-\height}[0pt][0pt]{\includegraphics[width=3.0cm]{example-image}}} %started with this}
\begin{choices}
\choice $1\ volt = 1\ amp \times 1 \Omega$
\choice $1\ amp = \frac{1\ volt}{1 \Omega}$
\choice $1 \Omega = \frac{1\ volt}{1\ amp}$
\CorrectChoice All of the above are true.
\end{choices}
\question[1] In a parallel circuit,
\begin{choices}
\choice the voltage is the same throughout the circuit, but the
current is divided.
\choice The total circuit resistance is always less than the smallest
resistor in the circuit.
\choice there is more than one path for current to flow.
\CorrectChoice All of the above are true.
\end{choices}
\question[1] An electronic device which acts like a high speed switch
is a
\begin{choices}
\choice triode
\choice diode
\choice monode
\correctchoice transistor
\end{choices}
\end{questions}
\end{document}
附注:请考虑使用siunitx
排版单位包。这样可以轻松输入单位\SI{1}{\ampere}
,间距也都正确。