![如果我需要根据问题编号选择不同的答案,可以自动化吗?](https://linux22.com/image/478608/%E5%A6%82%E6%9E%9C%E6%88%91%E9%9C%80%E8%A6%81%E6%A0%B9%E6%8D%AE%E9%97%AE%E9%A2%98%E7%BC%96%E5%8F%B7%E9%80%89%E6%8B%A9%E4%B8%8D%E5%90%8C%E7%9A%84%E7%AD%94%E6%A1%88%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%87%AA%E5%8A%A8%E5%8C%96%E5%90%97%EF%BC%9F.png)
我问了一个与此相关的问题,但我没有一个可行的例子。这是原帖有没有办法根据问题编号选择替代答案。总而言之,我想根据问题的奇偶性做出具有不同起始数字的答案选择。我想我需要创建一个环境并设置引用问题计数器的条件语句,但我没有找到类似的例子。
感谢您的阅读!
\documentclass[12pt,a4paper]{report}
\pagestyle{plain}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\makeatletter
\newcommand{\skipitems}[1]{%
\addtocounter{\@enumctr}{#1}%
}
\makeatother
\begin{document}
\section{Passage I}
\begin{multicols}{2}
%-----------------------------------------------------------------------------------
%Intro paragraph
Intro paragraph place holder before starting questions
%-----------------------------------------------------------------------------------
\vspace{1cm}
\begin{enumerate}
\item Question 1
\begin{enumerate}[A.]
\item Choice A
\item Choice B
\item Choice C
\item Choice D
\end{enumerate}
\item Question 2
\begin{enumerate}[A., start = 6]
\item Choice F
\item Choice G
\item Choice H
\skipitems{1}
\item Choice J
\end{enumerate}
\item Question 3
\begin{enumerate}[A.]
\item Choice A
\item Choice B
\item Choice C
\item Choice D
\end{enumerate}
\item Question 4
\begin{enumerate}[A., start = 6]
\item Choice F
\item Choice G
\item Choice H
\skipitems{1}
\item Choice J
\end{enumerate}
\end{enumerate}
\end{multicols}
\end{document}
答案1
如果我正确理解了这个问题,那么类似这样的:
\documentclass[12pt,a4paper]{report}
\pagestyle{plain}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\makeatletter
\newcommand{\skipitems}[1]{%
\addtocounter{\@enumctr}{#1}%
}
\newcommand\startval{\ifodd\value{enumi} 1 \else 6 \fi}
\makeatother
\begin{document}
\section{Passage I}
\begin{multicols}{2}
%-----------------------------------------------------------------------------------
%Intro paragraph
Intro paragraph place holder before starting questions
%-----------------------------------------------------------------------------------
\vspace{1cm}
\begin{enumerate}
\item Question 1
\begin{enumerate}[A., start=\startval]
\item Choice A
\item Choice B
\item Choice C
\item Choice D
\end{enumerate}
\item Question 2
\begin{enumerate}[A., start=\startval]
\item Choice F
\item Choice G
\item Choice H
\skipitems{1}
\item Choice J
\end{enumerate}
\item Question 3
\begin{enumerate}[A., start=\startval]
\item Choice A
\item Choice B
\item Choice C
\item Choice D
\end{enumerate}
\item Question 4
\begin{enumerate}[A., start=\startval]
\item Choice F
\item Choice G
\item Choice H
\skipitems{1}
\item Choice J
\end{enumerate}
\end{enumerate}
\end{multicols}
\end{document}