为 tasks 增加左右 margin
tasks 宏包是用来输入像以下格式的列表:[attach]10228[/attach]
详细介绍及用法请自行用命令行运行 texdoc tasks 查看。
可调的参数很多,但缺少整体左右 margin 的设置,比如说,默认下:
[attach]10229[/attach]
(这里用其自带的 debug 参数显示了边框)
如果想让 a) 右移,移到比段首缩进更进,就只能增加 item-indent(默认 2.5em),比如增加到 4em ,结果是:
[attach]10230[/attach]
标号是右移了,但右边界没变,结果就是实际上相邻列距变大,内容宽度就窄了很多。
而其实我想要的是这样:
[attach]10231[/attach]
但我找遍 tasks 的文档都没找到类似于 left 或 leftmargin 之类的参数项,后来在 texlive 安装目录下的 texmf-dist 里搜索 tasks.sty ,找到后打开,再查找 margin ,看到:
[attach]10232[/attach]
看来是被定死了,于是我尝试修改它。
当然最好不要改变原文件,把 tasks.sty 复制到当前 tex 文档所在目录下再改即可,因为运行时是优先读取当前目录的文件的。
[attach]10233[/attach]
保存后,就可以在正文中用 \lmg=1.5em 来改变 leftmargin ,效果就是前面我想要的那个。
还可以设 rightmargin ,比如再加 \rmg=2.5em ,效果:
[attach]10234[/attach]
也可以随时改回去。
【注】对于不同版本的 tasks ,要修改的那段代码可能不同,所以这里不贴完整代码,只给出新增和修改的几句:[code]前面新增:
\newlength\lmg\setlength\lmg{0pt}
\newlength\rmg\setlength\rmg{0pt}
后面修改为:
\dim_set:Nn \leftmargin {\lmg}
\dim_set:Nn \rightmargin {\rmg}[/code]然后请自行操作。
测试文档:[code]\documentclass{article}
\usepackage{tasks}
\parindent=2em
\newcount\n
\newcommand\kk[1]{\loop\ifnum\n<\numexpr#1-1\relax
. . . . . . . . \advance\n by1\repeat\n=0. . . . . . . .}
\begin{document}
\kk9
\begin{tasks}(4)
\task the first
\task the second
\task the third
\task the fourth
\task*(3) the fifth item is way too long for this and needs three columns
\task the sixth
\task the seventh
\task*(2) the eighth item is way too long for this and needs two columns
\task the nineth
\task the tenth
\end{tasks}
\settasks{debug}
\kk9
\begin{tasks}(4)
\task \kk2 \task \kk3 \task \kk4 \task \kk5
\end{tasks}
\kk9
\begin{tasks}[item-indent=4em](4)
\task \kk2 \task \kk3 \task \kk4 \task \kk5
\end{tasks}
\kk9
\lmg=1.5em
\begin{tasks}(4)
\task \kk2 \task \kk3 \task \kk4 \task \kk5
\end{tasks}
\kk9
\rmg=2.5em
\begin{tasks}(4)
\task \kk2 \task \kk3 \task \kk4 \task \kk5
\end{tasks}
\kk9
\end{document}[/code]
页:
[1]