1

I would like to know how to control three aspects of the tasks environment:

  • How to eliminate extraneous space before the task counter,
  • How to control the space between tasks
  • How to set the paragraph formatting universally

In the following example, I would like the task numbers 1 and 5 to be flush with the left margin. I would also like to add space between the tasks so that, for example, task 5 and 6 are not so close together. Finally, I would like to set the paragraph formatting within each task to \raggedright without having to manually do it.

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

enter image description here

A.Ellett
  • 50,533

2 Answers2

2

here is a solution, with the help of the etoolbox package for the last requirement:

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

enter image description here

Bernard
  • 271,350
2

Settingcolumn-sep=1em, item-indent=1.3333em yields the results you desire:

enter image description here

The lengths are defined as

enter image description here

where item-offset I think should have been label-offset.

Notes:

  • The defaults are label-width=1em and label-offset=0.3333em. Hence, setting item-indent=1.3333em yields the task counter aligned with the margin.

  • The default for column-sep=0pt hence setting that value will increase the horizontal spacing.

  • You can just set \raggedright before the \begin{tasks} and that will be in effect for all the tasks.

Code:

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

Peter Grill
  • 223,288
  • Doubly appreciative of the visual since it reminded me that maybe I should update my version of LaTeX. And now that I've done so, I can see exactly what you pointed out. – A.Ellett Nov 01 '14 at 23:41
  • @A.Ellett: Yeah it helps. I really wish the enumitem package would include a similar image as well. – Peter Grill Nov 02 '14 at 00:27