2

I have a setup with 2 simple macros:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfkeys}

\begin{document}

\newcommand\mycmda[1]{
  \pgfkeys{/demo/mycmda, default, #1}
  \typeout{mycmda}
  hello
}

\newcommand\mycmdb[1]{
  \pgfkeys{/demo/mycmdb, default, #1}
  \typeout{mycmdb}
  world
}

\pgfkeys{
  /demo/.is family,
  /demo/mycmda/.is family,
  /demo/mycmdb/.is family
}

\pgfkeys{
  /demo/mycmda,
  foo/.estore in = \foo
}

\pgfkeys{
  /demo/mycmdb,
  bar/.estore in = \bar
}

\pgfkeys{
  /demo/mycmda,
  default/.style = {
    foo = abc
  }
}

\pgfkeys{
  /demo/mycmdb,
  default/.style = {
    bar = xyz
  }
}

% \mycmdb{bar=hello} % this works
\mycmdb{bar=\mycmda{foo=asdf}} % this errors

\end{document}

The problem is when I try to do the following:

\mycmdb{bar=\mycmda{foo=asdf}}

It gives this error:

! TeX capacity exceeded, sorry [input stack size=5000].
\pgfkeys@possiblespace #1-> \pgfkeys
                                     {/demo/mycmda, default, #1} \typeout {m...
l.52 \mycmdb{bar=\mycmda{foo=asdf}}

What I am trying to accomplish is evaluating that expression bar=\mycmda{foo=asdf} so it becomes bar=hello essentially. But instead it errors saying Use of \\mycmdb doesn't match its definition..

If I do this it works fine:

\mycmdb{bar=hello}

Wondering how to accomplish using these "nested expressions".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.