# How to define shorcuts for the tasks package with \def?

I tried to define the shortcuts

\documentclass{article}

\begin{document}
\bqcmt
\myitem This is a test
\eqcmt
\end{document}


But it does not work. The error is:

LaTeX Error: \begin{tasks} on input line 10 ended by \end {document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

                                               l.13 \end{document}


Why is it so? How can I define such shorcuts?

# A solution ?

The following seems to work

\documentclass{article}

\begin{document}
\bqcmt
\task This is a test
\task This is a test
\task This is a test
\eqcmt
\end{document}


as well as

\documentclass{article}

\begin{document}
\bqcmt{3}
\task This is a test
\task This is a test
\task This is a test
\eqcmt
\end{document}


# My new question ?

But I'm wondering if it is a good idea. Indeed, \begin{tasks} will normally scan the rest of the file for an \end{tasks}. With this "hack", I guess that this scan will not happen.

• Never do you, you even up with a poor sematics and code that is hard to read. Instead look into the features of your editor. Most editors today have the ability to insert small templates at a press of a button, thus one key stroke and you have all this written for you – daleif Aug 24 '18 at 13:36
• Then please explain those reasons? And why an inferior syntax is better? You will see it again and again here that we never recommend doing this. BTW did you try the standard trick of using the macro form of the environment? aka \tasks{2} and \endtasks (untested) – daleif Aug 24 '18 at 14:01
• The TeX engine doesn't know what an environment is. It simply expands macros. IIRC, \begin is simply \csname #1\endcsname and \end is \csname end#1\endcsname. – John Kormylo Aug 24 '18 at 14:37
• \begin only uses \csname because the name is passed as an argument. \tasks is fine. – John Kormylo Aug 24 '18 at 15:47
• Could you say a few words why you added a bounty to this question? Your edits already seem to solve your problem – siracusa Aug 27 '18 at 19:27

It's a bad idea.

Anyway, you can use a macro with delimited argument.

\documentclass{article}

\begin{document}

\bqcmt{3}
\eqcmt

\bigskip

\end{document}


You can define a “new task” for using \item as a separator.

\documentclass{article}

\begin{document}

\bqcmt{3}
\item a
\item b
\item c
\item d
\item e
\item f
\eqcmt

\end{document}

• Thanks for your answer. Is it also possible to redefine \task to \myitem or, better, to \item? Thanks – Colas Aug 28 '18 at 10:04
• @Colas It just takes reading the manual. – egreg Aug 28 '18 at 10:18
• Thanks @egreg. I tried various ways to define "\item=\task" but didn't think of reading the manual. Thanks a lot ! – Colas Aug 28 '18 at 14:56