0

I have defined a command for the jacobian matrix, such as follows

\newcommand{\Jacobian}[2][]{\operatorname{J}_{#1}{#2}}

The problem comes if I try to use it inside a tikzcd arrow, probably because of problems with interepreting the brackets. I want to write something like this:

\begin{tikzcd}
    \mathbb{R}^{2} \arrow[r,"\Jacobian[p]{f}"] &
    \mathbb{R}^{2}
\end{tikzcd}

And have an output as if I had typed

\begin{tikzcd}
    \mathbb{R}^{2} \ar[r, "\operatorname{J}_{p}{f}"] &
    \mathbb{R}^{2}
\end{tikzcd}

But if I try this, compilation fails with

ERROR: Argument of \tikz@quote@@parser has an extra }.

--- TeX said ---
<inserted text> 
\par 
l.152     \end{tikzcd}

--- HELP ---
From the .log file...

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

I tried putting braces in some reasonable places without success.

1

You have to enclose the whole command in braces inside the quotes.

\begin{tikzcd}
    \mathbb{R}^{2} \arrow[r,"{\Jacobian[p]{f}}"] &
    \mathbb{R}^{2}
\end{tikzcd}
| improve this answer | |
  • 1
    You should edit your question instead of posting an answer. If there is now an answer, many people will ignore your question. – user156344 Nov 6 '18 at 12:13

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.