2

With the help of the task package you can produce easily enumerated lists with two or more columns:

  • if you write \begin{tasks}... everything is printed in one column
  • if you write \begin{tasks}(2)... everything is printed in two columns
  • if you write \begin{tasks}(3)... everything is printed in three columns

I want to appear the columns under a certain condition. I tried something like

\newtoggle{twocolumn}
\togglefalse{twocolumn}

    % Task 3
    \begin{tasks}\iftoggle{twocolumn}{}{(2)}
    \task one
    \task two
    \task three
    \task four
    \end{tasks}

...but this doesn't work!

MWE

\documentclass{article} 
\usepackage{lipsum}    

\usepackage{tasks}

\usepackage{etoolbox}

\begin{document}

    % Task 1
    \begin{tasks}(2)
    \task one
    \task two
    \task three
    \task four
    \end{tasks}

    % Task 2
    \begin{tasks}
    \task one
    \task two
    \task three
    \task four
    \end{tasks}

\newtoggle{twocolumn}
\togglefalse{twocolumn}

    % Task 3
    \begin{tasks}%\iftoggle{twocolumn}{}{(2)}
    \task one
    \task two
    \task three
    \task four
    \end{tasks}

\end{document}

Screenshot

enter image description here

1 Answer 1

2

Change the iftoggle condition to:

\begin{tasks}(\iftoggle{twocolumn}{2}{1})

MWE:

\documentclass{article} 
\usepackage{lipsum}    
\usepackage{tasks}
\usepackage{etoolbox}

\begin{document}

\newtoggle{twocolumn}
\togglefalse{twocolumn} The toggle is false:

    % Task 3
    \begin{tasks}(\iftoggle{twocolumn}{2}{1}) 
    \task one
    \task two
    \task three
    \task four
    \end{tasks}

\toggletrue{twocolumn} The toggle is true:

  % Task 4
  \begin{tasks}(\iftoggle{twocolumn}{2}{1}) 
      \task one
      \task two
      \task three
      \task four
  \end{tasks}  

\end{document}

Result:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .