0

In this this question, we find ##! in the context of a \newcommand definition, and specifically right after the \addtablerow command from the etoolbox package is used. What does ##! mean here? Why is it used?

Here is the code from that answer in which the ##! appears after \addtablerow:

\newcommand{\myTable}[1]{
    \renewcommand*\do[1]{\addtablerow##1!}
    \begin{tabular}{|p{0.4\textwidth}|p{0.2\textwidth} | p{0.2\textwidth} |        p{0.2\textwidth}|}
        \hline
        Name & Role & Presence & Present \\ \hline
        \docsvlist{#1} \hline
    \end{tabular}
}

I don't see an explanation in the etoolbox or etex documentation, so I am not sure where this would be documented.

  • 2
    You dropped the numeral 1 from your question. ##1 is what you have to do when you \(re)newcommand with arguments within the definition of a \newcommand; this is so that the "inner" argument list can be distinguished from the "outer" argument list (which already uses #1). See https://tex.stackexchange.com/q/42463/119 – Willie Wong Nov 28 '23 at 22:43
  • 3
    Note this doesn't have anything specifically to do with etoolbox. The doubling of hashes is a general thing in TeX. – cfr Nov 29 '23 at 00:35
  • ## is standard tex processing and ! is a local definition made in the post that you cite, a line above the code you show here. – David Carlisle Nov 29 '23 at 00:49
  • 3
    The ! in the definition is an arbitrarily chosen delimiter for the loop. See Parse macro arguments char by char and for loop through these chars for a simple example. In that code \nil is used as the delimiter. In the code in your question ! is used just like \nil and in fact you can replace the ! with \nil in the corrected code in this answer to see that the choice is arbitrary. – Alan Munn Nov 29 '23 at 00:58

0 Answers0