LaTeX macro package of tasks

tasks packages

LaTeX list (list) is typically display item (item, entry) parallel to a vertical, a so-called "column" the origin of the table.
Level sub-column list, multiple items will soon dispersed to each column instead of one, often encountered in a multiple-choice exam, in LaTeX package has: enumcols (enumlists), Tasks (exsheets)
enumcols macro package is created Li Qing , TeXlive after 2018, with the template CTeX of conflict. Data in this chapter discuss the use of packages of tasks. The main tasks usage packages are as follows:

\begin{tasks}[<选项>](<列数>)
    \task item1
    \task item2
\end{tasks}

Example: choice of documents

\documentclass{ctexart}
% 导言区添加
\usepackage{tasks}
\settasks{                     %设置
    counter-format=tsk[A],     %编号
    label-format={\bfseries},  %加粗
    %item-indent={-0.1em},
    %label-offset={-0.05em}
}

% 测试用
\newcommand{\sample}{This is some sample text we will use to create a somewhat longer text spanning a
few lines. This is some sample text we will use to create a somewhat longer text
spanning a few lines}


\begin{document}

选择题有4个选项,分4列显示选项A,B,C,D。

\begin{enumerate}
    \begin{tasks}(4)
        \task $x^2 + y^2 = R^2$
        \task $\mathrm{E}=\mathrm{MC}^2$
        \task $e^{-i\pi} = 1$
        \task \sample
    \end{tasks}
\end{enumerate}

\end{document}

Example: item across a plurality of columns

\begin{tasks}(4)
    \task \sample
    \task* \texttt{*}占用后面的所有列\sample
    \task* 占用后面的所有列\sample
    \task*(2) \texttt{*}本身可以带选项,指定占用的列数\sample
    \task*[(x)] 指定该条目的编号为(x)
    \startnewitemline
    \task! 另起新条目并占用以后的所有列\sample
    \task \sample
\end{tasks}

Based on a list of tasks to define a new environment

\NewTasks{itemtasks}[\item] %以\item为分隔符

% 文档中
\begin{itemtasks}(3)
    \item \sample
    \item \sample
    \item \sample
\end{itemtasks}

Use as defined environment mytaskscan not be nested in the enumerateenvironment, prompt
"begin {mytasks} on input line 22 ended by \ end {itemtasks}"
or
"\ begin {itemtasks} on input line 22 ended by \ end {document}"

\NewTasks{itemtasks}[\item]    % 以\item为分隔符
\newenvironment{mytasks}[1][2]{
    \begin{itemtasks}(#1)
}{
    \end{itemtasks}
}

% 文档中
\begin{enumerate}
    \item 第一个问题选项如下
        \begin{mytasks}[2]
            \item $x^2 + y^2 = R^2$
            \item $\mathrm{E}=\mathrm{MC}^2$
            \item $e^{-i\pi} = 1$
            \item \sample
        \end{mytasks}
\end{enumerate}

mytasksIn accordance with \NewEnviron(xparse packet) defined by the standard method defined environment\itemtasks...\enditemtasks

\newenvironment{mytasks}[1][2]{
    \itemtasks(#1)
}{
\enditemtasks
}

% 文档中
\begin{enumerate}
    \item 第一个问题选项如下
        \begin{mytasks}[4]
            \item $x^2 + y^2 = R^2$
            \item $\mathrm{E}=\mathrm{MC}^2$
            \item $e^{-i\pi} = 1$
            \item \sample
        \end{mytasks}
\end{enumerate}

Use environ'包的\ NewEnviron` command definitions

\NewTasks{itemtasks}[\item]        % 以\item为分隔符

\usepackage{environ}
\NewEnviron{mytasksenv}[1][2]{
    \def\tempbegin{\begin{itemtasks}(#1)} 
            \expandafter\tempbegin\BODY 
        \end{itemtasks}
}{}

% 文档中
\begin{mytasksenv}[4]
    \item $x^2 + y^2 = R^2$
    \item $\mathrm{E}=\mathrm{MC}^2$
    \item $e^{-i\pi} = 1$
    \item $x^2 + y^2 = R^2$
\end{mytasksenv}

Use xparse'包的\ NewDocumentEnvironment` definitions

\usepackage{xparse}
\NewDocumentEnvironment{mytasksx}{}
  {\newTask(2)}
  {\endnewTask}

Guess you like

Origin www.cnblogs.com/ourweiguan/p/11005432.html