I understand that TeX macro arguments can be parsed using proper delimiters. And as the classic example goes in The TeXbook,

enter image description here

Along the same line, I tried to define a macro (for some special purpose, the following is actually a much simpler scenario of my situation),


\def\mycommand\cone\bgroup#1\egroup\ctwo #2.#3\end{#1:#2:#3}


\mycommand\cone{One}\ctwo Two.Three\end


Where, \cone and \ctwo are used/system defined macros, and I am not interested in these definitions, rather I would like to ignore them. My points of interest are the three arguments.

Now, when I try compile the above file, I get the error message,

! Use of \mycommand doesn't match its definition.
l.10 \mycommand\cone{
                     One}\ctwo Two.Three

This is where I get stuck.

Please note that the "\cone{One}\ctwo Two.Three" part is rather unalterable. So, any suggested change will have to be in the definition of \mycommand.

I know that as has been pointed out also in The TeXbook, the parameter list can not contain any braces. To circumvent this, I tried using \bgroup and \egroup.

\def\mycommand\cone\bgroup#1\egroup\ctwo #2.#3\end{#1:#2:#3}

would require explict \bgroup. It seems like you want

\def\mycommand\cone#1\ctwo #2.#3\end{#1:#2:#3}


\mycommand\cone{One}\ctwo Two.Three\end


 \mycommand\cone One\ctwo Two.Three\end

would have #1 = One

  • 3
    Indeed TeX strips off a pair of braces around a delimited argument if this doesn't lead to unbalanced braces (double dangerous bend at the end of page 203 that ends on the following page of the TeXbook). – egreg Nov 4 '13 at 17:02

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.