(Please suggest a better title!)

The following LaTeX document defines a macro called /PrintStuff. This macro uses pgfkeys to define one optional argument, rowidstring. The macro \rowidstring@tables is used to store the value assigned to that argument.

If I pass the macro \rowidstring as the value to the rowidstring argument, I get the following error.

! Use of \rowidstring doesn't match its definition.
\pgfkeys@code ... ->\edef \rowidstring @tables{#1}

This problem disappears if I use \foobar, for example.

Clearly TeX is unhappy that I'm using the same string \rowidstring as part of the name of two different macros, but beyond that I'm not clear what the problem is.

And technically aren't \rowidstring@tables and \rowidstring two different macro names?

Running a trace on the document produces huge quantities of output, but nothing I can understand.

Also, it's convenient to use the same string in both places as I am doing here. So is there a workaround that will let me do this?


  /printstuff/.is family, /printstuff,
  default/.style =
  rowidstring/.estore in = \rowidstring@tables,
  rowidstring/.default = {},

  \pgfkeys{/printstuff, default, #1}%
  \typeout{ROWIDSTRING is \rowidstring@tables}




  • 3
    you are missing \makeatletter May 26 at 17:56
  • @UlrikeFischer Oh, I see. Yes, that fixes this example. Thank you. Does that mean there is nothing wrong with this usage, then? Though now I'm wondering why it doesn't give an error when I use \foobar. May 26 at 18:00
  • I didn't look, I only saw the space before the @ \edef \rowidstring @tables{#1} and guessed ... May 26 at 18:03
  • Though my actual code has the definition of the macro in a .sty file, so that should be OK, shouldn't it? I'll go back and check. May 26 at 18:06
  • Your usage is fine as long as you don't miss the \makeatletter. It works if you don't pass in \rowidstring as part of the value because the only usage after your key assignment has the correct parameter pattern (literal @tables immediately following). In your .estore in it is tried to fully expand \rowidstring without @tables following (and each time you use \PrintStuff your default resets the faulty definition).
    – Skillmon
    May 26 at 20:12

1 Answer 1


Lets first reduce what .estore in does. Your key is in principle identical to


But pgfkeys doesn't check whether <macro> really is a single token. In your case @ is of category 12, and hence your rowidstring is identical to

\edef\rowidstring @tables{<value>}

If you use this you define a macro \rowidstring that has the argument pattern @tables (so expects that literal input directly following it).

Each time you call default you do \edef\rowidstring @tables{} so you define the macro to expect the input @tables and expand to nothing. When you use that in your code everything's fine, because your usage of \rowidstring is normally followed by @tables in \PrintStuff (because you originally wanted to use the control word \rowidstring@tables).

Now in your breaking usage of \PrintStuff[rowidstring=\rowidstring] what you implicitly do is

\edef\rowidstring @tables{} % the effect of `default`
\edef\rowidstring @tables{\rowidstring}

The first overwrites your \newcommand{\rowidstring}{id1,id2} by the macro expecting to be followed by @tables. The second then uses this macro, but it is followed by } and not by @tables. TeX tries to expand that in \edef, but it can't and throws the error

! Use of \rowidstring doesn't match its definition.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .