4

There seems to be an incompatibility between these two packages.

Look at these two MWE:

The right one

\documentclass{article}
\usepackage{tasks}
%\usepackage[french]{babel}
\begin{document}

\begin{tasks}(3)
\task aaa
\task! fff 
\task bbb
\task ccc
\task ddd
\task eee
\end{tasks}

\end{document}

enter image description here

The wrong one

\documentclass{article}
\usepackage{tasks}
\usepackage[french]{babel}
\begin{document}

\begin{tasks}(3)
\task aaa
\task! fff 
\task bbb
\task ccc
\task ddd
\task eee
\end{tasks}

\end{document}

enter image description here

  • This post is to report this incompatibility

  • Does someone have an nice idea on how to solve this issue?

6

I wouldn't call this "solving", but you can use etoolbox's \AtBeginEnvironment hook to deactivate the ! inside the tasks environment:

\documentclass{article}
\usepackage{tasks}
\usepackage[french]{babel}

\usepackage{etoolbox}
\AtBeginEnvironment{tasks}{\catcode`\!12}

\begin{document}

\begin{tasks}(3)
\task aaa
\task! fff
\task bbb
\task ccc
\task ddd
\task eee
\end{tasks}

\end{document}

If you want to keep the active ! then you can use a more brute-force approach and change the character used to denote a full-line task. For instance with +:

\documentclass{article}
\usepackage{tasks}
\usepackage[french]{babel}

\ExplSyntaxOn
\cs_gset_protected:Npn \__tasks_read_item:www
  {
    \peek_meaning_remove:NTF + % <-- Character to activate a full-line task
      {
        \bool_set_true:N \l__tasks_item_full_line_bool
        \__tasks_read_item_aux:ww
      }
      {
        \peek_meaning_remove:NTF *
          {
            \bool_set_true:N \l__tasks_item_rest_of_line_bool
            \__tasks_read_item_rest_of_line:ww
          }
          { \__tasks_read_item_aux:ww }
      }
  }
\ExplSyntaxOff

\begin{document}

\begin{tasks}(3)
\task aaa
\task+ fff
\task bbb
\task ccc
\task ddd
\task eee
\end{tasks}

\end{document}

After some digging:

jfbu suggested using \expandafter\task\string! or defining a \taskexclam to be \task <the character !>.

These don't work because tasks uses \task as a dummy control sequence to split the collected contents of the environment. So internally this:

\begin{tasks}(3)
\task aaa
\expandafter\task\string! fff
\task bbb
\taskexclam ccc
\task eee
\end{tasks}

is transformed into the list:

{ aaa \expandafter }
{ \string! fff }
{ bbb \taskexclam ccc }
{ eee }

which makes the \expandafter trick useless and the \string! will simply write a !. The \taskexclam is also executed too late, so it has no effect.

An approach that obeys tasks' rules and preserves the meaning of ! in french is copying the character definition of ! before loading babel then using the new name:

\documentclass{article}

\let\exclam=!

\usepackage[french]{babel}
\usepackage{tasks}

\begin{document}

\begin{tasks}(3)
\task aaa
\task\exclam fff
\task bbb
\task ccc
\task ddd
\task eee
\end{tasks}

\end{document}
  • 1
    unfortunately tasks seems to be gathering its contents because \expandafter\task\string! fails... – user4686 Oct 13 '18 at 15:43
  • 1
    and for same reason it seems impossible to use \taskexclam in place of \task! with \taskexclam defined to expand to \task <catcode twelve !>. So task package makes it hard to work around that problem if not using your approach which however has the problem that ! in items will not be correctly typeset for French. – user4686 Oct 13 '18 at 15:48
  • 1
    @jfbu Good point... Indeed, tasks uses environ's \NewEnviron to collect the contents of the environment. It then uses \peek_meaning_remove:NTF to check for the !. One would have to trick this test to get it working with the active !... – Phelype Oleinik Oct 13 '18 at 15:57
  • 1
    maybe OP should send a Feature Request to tasks for either allow active ! or allow to specify another character for that job... or allow some \taskfullwidth in place of \task!. – user4686 Oct 13 '18 at 16:06
  • 1
    @jfbu Searching a bit further in the code of tasks I found out that \taskexclam and \expandafter\task\string! don't work because the package uses \task not as a command, like \item but as a separator for \seq_set_split:Nnn, so \taskexclam gets executed only at the proper typesetting stage, and belongs to the previous item, and \expandafter\task\string! puts the \expandafter in a separate item than \string!. Using \let\exclam=! before loading babel and using \task\exclam seems like a better approach, though. – Phelype Oleinik Oct 13 '18 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.