我想知道如何控制tasks
环境的三个方面:
- 如何消除任务计数器前的无关空间,
- 如何控制任务之间的间隔
- 如何统一设置段落格式
在以下示例中,我希望任务编号1
和5
与左边距齐平。我还想在任务之间添加空格,以便例如任务5
和6
不会太靠近。最后,我希望设置每个任务中的段落格式,而\raggedright
无需手动执行此操作。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=1in]{geometry}
\newcommand\sample{This is a sample sentence that spans more than one line of the final documents.}
\usepackage{tasks}
\usepackage{enumitem}
\setlength{\parindent}{0pt}
\begin{document}
\noindent
\raisebox{0pt}[0pt][0pt]{\rule[-4in]{0.4pt}{4in}}%%
\sample \sample \sample
\begin{tasks}[counter-format={\bfseries tsk[1].}](4)
\task This
\task that
\task something else
\task something even more
\task \sample \sample
\task \sample more more more
\task \raggedright\texttt{\detokenize{\raggedright}} set here. \sample
\task something
\end{tasks}
\end{document}
答案1
设置column-sep=1em, item-indent=1.3333em
会产生您想要的结果:
长度定义为
我认为item-offset
应该如此label-offset
。
笔记:
默认值为
label-width=1em
和label-offset=0.3333em
。因此,设置item-indent=1.3333em
将产生与边距对齐的任务计数器。因此设置该值的默认值
column-sep=0pt
将增加水平间距。你可以设置
\raggedright
前并且\begin{tasks}
将对所有的都有效tasks
。
代码:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=1in]{geometry}
\newcommand\sample{This is a sample sentence that spans more than one line of the final documents.}
\usepackage{tasks}
\usepackage{enumitem}
\setlength{\parindent}{0pt}
\begin{document}
\noindent
\raisebox{0pt}[0pt][0pt]{\rule[-4in]{0.4pt}{4in}}%%
\sample \sample \sample
{\raggedright%
\begin{tasks}[counter-format={\bfseries tsk[1].}, column-sep=1em, item-indent=1.3333em](4)
\task This
\task that
\task something else
\task something even more
\task \sample \sample
\task \sample more more more
\task \raggedright\texttt{\detokenize{\raggedright}} set here. \sample
\task something
\end{tasks}}
\end{document}
答案2
这是一个解决方案,借助etoolbox
最后一个要求的包:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=1in, showframe, nomarginpar]{geometry}
\newcommand\sample{This is a sample sentence that spans more than one line of the final documents.}
\usepackage{tasks}
\usepackage{enumitem}
\setlength{\parindent}{0pt}
\usepackage{etoolbox}
\AtBeginEnvironment{tasks}{\raggedright}
\settasks{column-sep=1.5em, item-indent=1.3333em}%
\begin{document}
\noindent
\raisebox{0pt}[0pt][0pt]{\rule[-4in]{0.4pt}{4in}}%%
\sample \sample \sample
\begin{tasks}[counter-format={\bfseries tsk[1].}](4)
\task This
\task that
\task something else
\task something even more
\task \sample \sample
\task \sample more more more
\task \raggedright\texttt{\detokenize{\raggedright}} set here. \sample
\task something
\end{tasks}
\end{document}