5

I have a problem with tikzcd.

I want to make the following diagram:

\begin{tikzcd}
G \ar[d, two heads, swap, "\varphi_1"] \ar[r, "\varphi_2"] & F_2 \\
F_1 \ar[ur, dashed, swap, "\varphi"] &
\end{tikzcd}

When I put it in a separate document, it works just as it should. But when I put it into a full document and compile it with MikTex (using Texworks) I get the following error:

! Missing \endcsname inserted.
<to be read again> 
               \varphi 
l.260 \end{tikzcd}

Any ideas what I can do with it?

  • 1
    (1) welcome, (2) the best thing to do is take your problematic file, give it a new name. Start deleting/out commenting stuff, recompile, repeat. Then you'll figure out what is important to this issue, and what is not. Then post the result. As it fits now we cannot help as we have no information about the problematic doc. – daleif Sep 26 '16 at 20:18
7

Based on your name, I suspect your document is something like

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[polish]{babel}

\usepackage{tikz-cd}

\begin{document}

\title{Tytuł}
\author{Paweł Piwek}

\maketitle

\begin{tikzcd}
G \ar[d, two heads, swap, "\varphi_1"] \ar[r, "\varphi_2"] & F_2 \\
F_1 \ar[ur, dashed, swap, "\varphi"] &
\end{tikzcd}

\end{document}

In this case, the first error message, which is the one you should report, is

! Argument of \language@active@arg" has an extra }.
<inserted text> 
                \par 
l.18 \end{tikzcd}

and this is a babel problem. Fix it with \usetikzlibrary{babel}.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[polish]{babel}

\usepackage{tikz-cd}
\usetikzlibrary{babel}

\begin{document}

\title{Tytuł}
\author{Paweł Piwek}

\maketitle

\begin{tikzcd}
G \ar[d, two heads, swap, "\varphi_1"] \ar[r, "\varphi_2"] & F_2 \\
F_1 \ar[ur, dashed, swap, "\varphi"] &
\end{tikzcd}

\end{document}

enter image description here

| improve this answer | |
3

For me the problems were caused by loading Babel with ngerman, i.e. \usepackage[ngerman]{babel}. Unfortunately, \usetikzlibrary{babel} suggested in the other answer did not fix the problem.

The solution which worked for me was to make " inactive again:

\begin{document}

  % Then very soonish execute the following:
  \shorthandoff{"}

  ...
...
| improve this answer | |
  • 2
    This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question. - From Review – BambOo Jun 19 '19 at 11:16
  • @BambOo I don't have a question, instead, I wanted to give users visiting this question e.g. from Google (cf. the view count of 700!) an "additional" fix. Indeed, my answer might not have been the solution for OP, but at least on StackOverflow it's common to give additional useful answers to highly viewed questions. – ComFreek Jun 19 '19 at 11:58
  • IMHO, your answer is right (solves the OP issue) in the content but wrong in the form. Here, this type of answer is more likely to be a comment. Moreover, if your comment is relevant enough, people tend to ask you to re-post it as an answer. Finally, there are several clashes between babel and tikz, hence the answer from egreg and the babel tikzlibrary. – BambOo Jun 19 '19 at 13:06
  • @BambOo I was under the impression that comments with contents (and which do not simply ask for clarification) are discouraged throughout the SE network. At leave I've already seen users being called out for this on multiple sites. Indeed, egreg's answer did not solve it in my case. I added that to the answer. – ComFreek Jun 19 '19 at 13:13
1

I wanted to just add this in as a comment, but I'm new here. I thought it was worth mentioning that I encountered the same error message while using square brackets in tikzcd:

\begin{tikzcd}[row sep=tiny]

[ \Sigma^j X, \Sigma^j Y ]  \arrow{dr}{\phi_j} \arrow{dd}{\Sigma^{i}}\\

& Z \\

[ \Sigma^{i+j} X, \Sigma^{i+j} Y ] \arrow{ur}[below]{\phi_{i+j}}

\end{tikzcd}

It was solved by replacing [ and ] with \left[ and \right].

| improve this answer | |
  • 1
    Welcome to TeX.SX!. The error is different, and can be solved by changing \\ into \\ \relax when a bracket [ follows \\. Another method is using \lbrack and \rbrack instead of [ and ]. – egreg Oct 30 '18 at 17:20
0

I had a very similar problem (Missing \endcsname inserted.) with a Tikz figure.

None of the above answers worked (even though I am using babel), so, after lots of searching, I commented out my package imports one by one, and found that the siunitx package singlehandedly caused the Tikz figure to crash at compilation. Might help someone out with the same error message and usage of Tikz.

| improve this answer | |
  • Welcome to TeX.SE! – Mensch Jun 20 at 14:07

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.