Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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),

\documentclass{article}

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

\begin{document}

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

\end{document}

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.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted
\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}

Then

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

or

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

would have #1 = One

share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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