两栏文本问题和选择

两栏文本问题和选择

我正在尝试为匹配类型的问题创建一个命令。左栏是问题,右栏是选项。我的问题是如何做到这一点,特别是在右栏上。我如何才能使选项列与问题总数的长度相对应?

示例输出为:

在此处输入图片描述

后续问题。如果不管写什么a. choice1,是否可以将字母 a 改为小方框?

如果可以使用这样的命令会更好:

  \documentclass{exam}
  \usepackage{longtable,tabu}
  \begin{document}
  \begin{mytabu}\boxedcolchoice
  \question{text text text text text}{choice1}\\
  \question{text text text text text here text here}{choice2}\\
  \end{mytabu}
  \end{document}

答案1

这是一个可能的解决方案,使用tabulongtable包。该命令\myquestion负责排版条目;它有两个强制参数:第一个参数包含问题的文本,第二个参数包含选项的相应文本。行编号和框会自动包含在内:

\documentclass{article}
\usepackage{longtable}
\usepackage{tabu}

\newcounter{myrow}
\newcommand\mybox{%
  \raisebox{0.25ex}{\fbox{\rule{0.5em}{0pt}\rule{0pt}{0.5em}}}}
\newcommand\myquestion[2]{& #1 & & #2}

\begin{document}

\tabulinesep=3pt
\begin{longtabu} to \textwidth{
  >{\stepcounter{myrow}\themyrow.}l
  X[3]
  @{\hspace*{2em}}
  >{\mybox}l
  @{\hspace*{4pt}}X
}
\myquestion{Here's the text for the first question; and we add some text to apan more than one line.}{choice1}  \\
\myquestion{Here's the text for the second question; and we add some text to apan more than one line; and we add some text to apan more than one line; and we add some text to apan more than one line.}{choice2}  \\
\end{longtabu}

\end{document}

在此处输入图片描述

注释中提出了一项新要求;能够将宽度longtabu和格式规范作为参数;这可以通过定义一个mytabu具有两个强制参数的新环境来实现(第一个参数也可以定义为具有默认值的可选参数):第一个参数是的宽度longtabu,第二个参数给出格式规范。代码:

\documentclass{article}
\usepackage{longtable}
\usepackage{tabu}

\newcounter{myrow}
\newcommand\mybox{%
  \raisebox{0.25ex}{\fbox{\rule{0.5em}{0pt}\rule{0pt}{0.5em}}}}
\newcommand\myquestion[2]{& #1 & & #2}
\newenvironment{mytabu}[2]
  {\tabulinesep=3pt
    \begin{longtabu} to #1{#2}
  }
  {\end{longtabu}}

\begin{document}

\begin{mytabu}{\textwidth}{
  >{\stepcounter{myrow}\themyrow.}l
  X[3]
  @{\hspace*{2em}}
  >{\mybox}l
  @{\hspace*{4pt}}X
}
\myquestion{Here's the text for the first question; and we add some text to apan more than one line.}{choice1}  \\
\myquestion{Here's the text for the second question; and we add some text to apan more than one line; and we add some text to apan more than one line; and we add some text to apan more than one line.}{choice2}  \\
\end{mytabu}

\end{document}

现在对原始问题进行编辑,提出了一个新要求:

\documentclass{article}
\usepackage{longtable}
\usepackage{tabu}

\newcounter{myrow}
\newcommand\mybox{%
  \raisebox{0.25ex}{\fbox{\rule{0.5em}{0pt}\rule{0pt}{0.5em}}}}
\newcommand\myquestion[2]{& #1 & & #2}
\newenvironment{mytabu}
  {\tabulinesep=3pt
    \begin{longtabu} to \textwidth{>{\stepcounter{myrow}\themyrow.}l
  X[3]
  @{\hspace*{2em}}
  >{\mybox}l
  @{\hspace*{4pt}}X}
  }
  {\end{longtabu}}

\begin{document}

\begin{mytabu}
\myquestion{Here's the text for the first question; and we add some text to apan more than one line.}{choice1}  \\
\myquestion{Here's the text for the second question; and we add some text to apan more than one line; and we add some text to apan more than one line; and we add some text to apan more than one line.}{choice2}  \\
\end{mytabu}

\end{document}

在此处输入图片描述

相关内容