I have seen What are the consideration when choosing either newcommand or newenvironment? but I think this is a little more specific. If it's a duplicate, then so be it. If the second part of the question is too speculative, then I can edit it out.
Let's say I were making an exam class (I know there are many, but just for example).
\documentclass{myexam}
% preamble
\begin{document}
% content
\end{document}
Clearly, if would be nice for such a class to provide a \question
command of some sort. Two approaches would be:
(1) Provide a \question
macro.
\documentclass{myexam}
% preamble
\begin{document}
\question Here is my question.
\end{document}
(2) Provide a \begin{questions}
environment (list).
\documentclass{myexam}
% preamble
\begin{document}
\begin{questions}
\question Here is my question.
\end{questions}
\end{document}
I have two related questions:
- If
\begin{questions}
were hidden in something like\AtBeginDocument
, then to the user, the approaches are (mostly) identical. In such a case, does either approach offer any specific advantage/disadvantage? - Is one approach semantically superior? For example, would a competent user expect one or the other?
One possible disadvantage of the environment/list approach would be that to add a non-question, the environment/list may need to be explicitly stopped and restarted.
verbatim
package).\question <Content here>
would definitely be unusual. Out of a specific environment (itemize
, etc for\item
orquestions
forquestion
) command arguments should always be delimited by braces or square brackets. And even in these environments, this ambiguity of the language is a valid point raised regularly by latex competitors.exam
class uses approach (2), i.e. the list like one. For myexsheets
package I decided to use an environment for each question to be able so suppress them on a per question basis...