2

I saw some tricks here Problem with babel and tikz using \draw

but it seems I can't use them.
If I say in my MWE
\usepackage[ngerman]{babel}
\usepackage[autostyle=true,german=quotes]{csquotes}

and later
\def\Symbol{X}
\pgfmathsetlengthmacro\symbolwidth{0.5*width("\Symbol")},
he gives me

! Package PGF Math Error: Unknown function `X' (in '0.5*width("X")').

What have I to do?

enter image description here

% I need
% arara: lualatex 
% if this is an important info.

\documentclass{article}

% needed: ====== \usepackage[ngerman]{babel} \usepackage[autostyle=true,german=quotes]{csquotes}

% needed: ====== \usepackage{tikz} \usetikzlibrary{babel}

\def\Symbol{X} \begin{document} \section{Quotation Marks} \enquote{test} \glqq test 2\grqq

\section{TikZ} % needed: ====== \pgfmathsetlengthmacro\symbolwidth{0.5width("\Symbol")} \pgfmathsetlengthmacro\symbolheight{0.5height("\Symbol")} \begin{tikzpicture}[x=\symbolwidth, y=\symbolheight] \node[draw]{\Symbol}; \end{tikzpicture}

\end{document}

cis
  • 8,073
  • 1
  • 16
  • 45
  • Usage of \Symbol is irrelevant and also csquotes. Apparently the syntax is broken even if the babel library is used. – egreg Jun 12 '20 at 17:11

1 Answers1

3

The babel library enters the scene only inside a tikzpicture (thanks to Ulrike Fischer for pointing it out).

The problem is independent of \Symbol (also the simple X triggers the error) and of csquotes.

Workaround: use \string".

\documentclass{article}

% needed: ====== \usepackage[ngerman]{babel} \usepackage[autostyle=true,german=quotes]{csquotes}

% needed: ====== \usepackage{tikz} \usetikzlibrary{babel}

\def\Symbol{X} \begin{document} \section{Quotation Marks} %\enquote{test} \glqq test 2\grqq

\section{TikZ} % needed: ====== \pgfmathsetlengthmacro\symbolwidth{0.5width(\string"\Symbol\string")} \pgfmathsetlengthmacro\symbolheight{0.5height(\string"\Symbol\string")} \begin{tikzpicture}[x=\symbolwidth, y=\symbolheight] \node[draw] at (0,0) {\Symbol}; \node[draw] at (4,0) {\Symbol}; \end{tikzpicture}

\end{document}

enter image description here

egreg
  • 1,121,712