tasks 宏包

LaTeX的列表(list)通常是将项(item,条目)一个一个垂直的平行显示,所谓“列”表的由来。

水平分列列表,即将多个项分散到各列而不是一列,在出考卷的选择题时常碰到,LaTeX中的包有:enumcols(enumlists)、tasks(exsheets)

enumcols宏包是李清创建的,TeXlive 2018后,与CTeX的模板冲突。本篇主要讨论tasks宏包的使用。tasks宏包的主要用法如下:

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

例:选择题的文档

\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}

例:跨越多个列的项

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

基于tasks定义新列表环境

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

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

使用如下定义的环境mytasks不能嵌套在enumerate环境,提示

“begin{mytasks} on input line 22 ended by \end{itemtasks}”



“\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}

mytasks是按照\NewEnviron(xparse包)定义的,标准的环境定义方法使用\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}

使用environ'包的\NewEnviron`命令定义

\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}

使用xparse'包的\NewDocumentEnvironment`定义

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

完整的示例

%!TEX program = xelatex
\documentclass[UTF8]{ctexart} \usepackage{url}
\usepackage{tasks}
\settasks{
counter-format=tsk[A],
label-format={\bfseries},
%item-indent={-0.1em},
%label-offset={-0.05em}
} \NewTasks{itemtasks}[\item]
%\newenvironment{mytasks}[1][2]{
% \begin{itemtasks}(#1)
%}{
% \end{itemtasks}
%} \newenvironment{mytasks}[1][2]{
\itemtasks(#1)
}{
\enditemtasks
} %https://tex.stackexchange.com/questions/237230/tasks-in-custom-environment
\usepackage{environ}
\NewEnviron{mytasksenv}[1][2]{
\def\tempbegin{\begin{itemtasks}(#1)}
\expandafter\tempbegin\BODY
\end{itemtasks}
}{} \usepackage{xparse}
%https://tex.stackexchange.com/questions/391459/nesting-tasks-within-an-xparse-environment
\NewDocumentEnvironment{mytasksx}{}
{\itemtasks(2)}
{\enditemtasks} \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} \begin{mytasksenv}[4]
\item six, 继续上面的编号.
\item seven
\item seven
\item seven
\end{mytasksenv} \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} \begin{tasks}(4)
\task* 一般使用格式为\texttt{\\begin\{tasks\}[选项](列数)}
\task 可使用\texttt{*}
\task three
\end{tasks} \begin{tasks}[resume=true]
\task six, 继续上面的编号.
\task seven
\end{tasks} This is some sample text we will use to create a somewhat longer text spanning a
few lines. \begin{enumerate}
\item 在LyX中,定义新环境itemtasks,用item分隔符!不会与外面的item冲突!但是LyX插入的选项放在中括号汇总,而tasks要求放在小括号中。
\item \url{http://troubleshooters.com/linux/lyx/ownlists.htm}不知道说啥
\item 第二个问题有如下的选项
\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}
\item 第三
\begin{tasks}(2)
\task $x^2 + y^2 = R^2$
\task $\mathrm{E}=\mathrm{MC}^2$
\task $e^{-i\pi} = 1$
\task $e^{-i\pi} = 1$
\end{tasks}
\end{enumerate} \begin{tasks}(4)
\task \sample
\task* \texttt{*}占用后面的所有列\sample
\task* 占用后面的所有列\sample
\task*(2) \texttt{*}本身可以带选项,指定占用的列数\sample
\task*[(x)] 指定该条目的编号为(x)
\startnewitemline
\task! 另起新条目并占用以后的所有列\sample
\task \sample
\end{tasks} \end{document}

LaTeX的tasks宏包的更多相关文章

  1. LaTeX使用titlesec宏包改变章节编号形式的方法

    1.titleformat宏包命令详解 LaTeX中可以用titlesec宏包中的titleformat命令来改变标题形式: 导入宏包: \usepackage{titlesec} 改变标题的代码如下 ...

  2. LaTeX的一些宏包及细节知识

    文章来源:LaTeX的一些宏包及细节知识http://blog.chinaunix.net/uid-20289887-id-1710422.html ps:我的机器上软件并不能直接运行通,下面“代码” ...

  3. Windows 下 LaTeX 手动安装宏包(package)以及生成帮助文档的整套流程

    本文简单介绍如何手动安装一个 LaTeX 宏包. 一般来说,下载的 TeX 发行版已经自带了很多宏包,可以满足绝大部分需求,但是偶尔我 们也可能碰到需要使用的宏包碰巧没有安装的情况,这时我们就需要自己 ...

  4. LaTeX手动安装宏包(package)以及生成帮助文档的整套流程

    注意:版权所有,转载请注明出处. 我使用的是ctex套装,本来已经自带了许多package,但是有时候还是需要使用一些没有预装的宏包,这时就需要自己安装package了.下载package可以从CTA ...

  5. LaTeX中titlesec宏包的使用

    在 xelatex 中使用 \usepackage 指令使用 titlesec 宏包时,可以指定一些格式选项,如下: \usepackage[center]{titlesec} 其中 center 可 ...

  6. LaTeX源代码显示宏包listings应用备忘之新语言定义

      我目前了解的LaTeX中有关源代码显示的宏包有两个,这里介绍其中的listings宏包.listings宏包中已经定义了部分计算机语言的显示样式,但还是有些语言没有定义,我们一起看一下如何定义新的 ...

  7. [原创][LaTex]LaTex学习笔记之框架及宏包

    0. 简介 LaTex在书写文档时的最基本单元就是首部的写作,变相的也可以说是头文件.本文章就来总结一下文档的基本格式和常用宏包. 1. 基本单元 基本单元需要对LaTex语法有一定的了解,这个很简单 ...

  8. 在LaTeX中利用preview宏包和tikz宏包生成单图pdf

    有时候我们利用tikz宏包画出的图片后,只想生成一个单图pdf,而且pdf的页面大小与图片相同,以便于以后再次用latex插入. 可以与preview宏包进行搭配,页面大小由图像大小决定,可以通过改变 ...

  9. LaTeX自定义宏包、类文件的默认搜索路径设置方法

      对于自定义的LaTeX宏包与类,在调用时可以通过在命令\documentclass{}与\usepackage{}命令中指定完整路径或者相对路径,这样确实可以调用,但是编译时总是有烦人的警告信息, ...

随机推荐

  1. Java Web使用过滤器防止Xss攻击,解决Xss漏洞

    转: Java Web使用过滤器防止Xss攻击,解决Xss漏洞 2018年11月11日 10:41:27 我欲乘风,直上九天 阅读数:2687   版权声明:本文为博主原创文章,转载请注明出处!有时候 ...

  2. [spring]基于注解的spring配置

    Spring是一个基于IOC和AOP的结构J2EE系统的框架 IOC 反转控制 是Spring的基础,Inversion Of Control 简单说就是创建对象由以前的程序员自己new 构造方法来调 ...

  3. Selenium 2自动化测试实战30(unittest补充)

    unittest补充 1.用例执行的顺序 #test.py #coding:utf-8 from Demo1 import Count import unittest class TestBdd(un ...

  4. 阶段3 3.SpringMVC·_06.异常处理及拦截器_4 SpringMVC拦截器之介绍和搭建环境

    拦截器可以有多个 搭建环境 不用改,直接finish 复制原来项目的 依赖的包也复制过来 web.xml配置前端控制器 springmvc的配置文件 先创建对应的文件夹 分别创建java和resour ...

  5. GB 和 GiB 的区别

    GB 和 GiB 的区别 Gibibyte (GiB) is one of the standard units used in the field of data processing and da ...

  6. Codeforces--Balanced Tunnel

    问题重述 Codeforces --- Balanced Tunnel 见链接http://codeforces.com/contest/1237/problem/B. Solve 这道题的本质是找递 ...

  7. app测试基础知识之命令

    app测试点:功能测试,安全测试,用户体验测试,交叉事件测试,兼容性测试,性能测试,安装/升级/卸载 ,UI测试 命令操作: adb connect 名 adb devices adb  instal ...

  8. Linux-T

    vim编辑器i输入Esc切换:wqw保存q退出保存 查看openssl版本号openssl version 查看所有php扩展php -m 查看指定端口占用netstat -anp |grep xxx ...

  9. linux环境jdk+tomcat搭建

    一.什么是Linux? 和Windows操作系统软件一样,Linux也是一个操作系统软件.但是和Windows不同的是,Linux是一套开放源代码程序的.并可以自由传播的类Unix操作系统软件(Uni ...

  10. 【神经网络与深度学习】GLog使用笔记

    环境: XPsp3 vs2005 glog-0.3.3 http://download.csdn.net/detail/chenguangxing3/6661667 编译: glog-0.3.3里面有 ...