使用 ExSheets 在成绩表中显示偶数和奇数问题

使用 ExSheets 在成绩表中显示偶数和奇数问题

我想使用该ExSheets包创建一个成绩表。不幸的是,表格对于标题页来说太长了。尝试过其他方法(例如 longtable-environment、resizebox 等)——没有一个特别令人满意——我正在寻找一种方法来分离由宏解决的偶数和奇数问题,\ForEachQuestion以将垂直表(参见下面的最小工作示例)分成两列。是否有开关可以做到这一点,或者有其他方法可以自动将表格排版为两列(每列由三个“子列”组成)?

由于计数器格式 ( ),检查计数器的偶数和奇数不起作用counter-format=se.qu

梅威瑟:

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{exsheets}

\SetupExSheets{
    counter-format=se.qu,
    counter-within=section,
    solution/print=true
    }


\begin{document}

\begin{center}
\begin{tabular}{lcc}
\hline
\textbf{Question}                           &     \textbf{Points}                   & \textbf{Result}   \\\hline
\ForEachQuestion{%
Question \GetQuestionProperty{counter}{#1}  & \GetQuestionProperty{points}{#1}  & {}                \iflastquestion{\\\hline}{\\}%
}
$\mathbf\Sigma$                         & \pointssum                        & {}                \\
\hline
\end{tabular}
\end{center}

\section{First}
\begin{question}{2}
Some question
\end{question}

\begin{question}{1}
Some question
\end{question}

\begin{question}{2}
Some question
\end{question}
\begin{question}{3}
Some question
\end{question}

\begin{question}{2}
Some question
\end{question}

\begin{question}{2}
Some question
\end{question}

\section{Second}

\begin{question}{10}
Some question
\end{question}

\begin{question}{10}
Some question
\end{question}

\end{document}

答案1

纯问题编号不是直接可用的,但可以添加属性来检索它。然后,为了能够正确构建表格,在实际排版表格之前,在宏中构建表格内容会更容易。

可能是这样的:

在此处输入图片描述

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{exsheets}

\SetupExSheets{
  counter-format = se.qu,
  counter-within = section,
  solution/print = true,
  question/post-hook = \SetQuestionPropertiesX{number=\arabic{question}}
}

% new property:
\DeclareQuestionProperty{number}

% a command that expands the property before saving it:
\ExplSyntaxOn
\NewDocumentCommand \SetQuestionPropertiesX { +m }
  { \exsheets_set_question_properties:x {#1} }
\ExplSyntaxOff

\providecommand*\printgradingtable{}

\begin{document}

% build the table contents:
\ForEachQuestion{%
  \ifodd\GetQuestionProperty{number}{#1}
    \eappto\printgradingtable{%
      Question \GetQuestionProperty{counter}{#1} &
      \GetQuestionProperty{points}{#1} & &
    }
  \else
    \eappto\printgradingtable{%
      Question \GetQuestionProperty{counter}{#1} &
      \GetQuestionProperty{points}{#1} &
      \iflastquestion{\unexpanded{\\\hline}}{\unexpanded{\\}}
    }
  \fi
}

\begin{center}
\begin{tabular}{lcclcc}
  \hline
    \textbf{Question} & \textbf{Points} & \textbf{Result} &
    \textbf{Question} & \textbf{Points} & \textbf{Result} \\
  \hline
    \printgradingtable
    $\mathbf\Sigma$ & & & & \pointssum & \\
  \hline
\end{tabular}
\end{center}

\section{First}
\begin{question}{2}
Some question
\end{question}

\begin{question}{1}
Some question
\end{question}

\begin{question}{2}
Some question
\end{question}
\begin{question}{3}
Some question
\end{question}

\begin{question}{2}
Some question
\end{question}

\begin{question}{2}
Some question
\end{question}

\section{Second}

\begin{question}{10}
Some question
\end{question}

\begin{question}{10}
Some question
\end{question}

\end{document}

exsheets代码利用了同时加载xparse和的事实etoolbox

相关内容