Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This code works correctly:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document}

\begin{tikzpicture}
  \tikzset{
    every picture/.prefix style={
      execute at begin picture=\shorthandoff{;}
    }
  }
  \def\names{{"1", "2"}}
  \foreach \i in {0,1} {%
    \ifnum\i=0\relax
      \node (\i) [draw] {\pgfmathparse{\names[\i]}\pgfmathresult};
    \else
      \pgfmathparse{int(\i-1)}
      \node (\i) [draw,right= 1cm of \pgfmathresult]
            {\pgfmathparse{\names[\i]}\pgfmathresult};
      \draw[dotted] ($(\pgfmathresult.south east) !.5! (\i.south west)$)
            -- +(0,1cm);
  \fi
}
\end{tikzpicture}
\end{document}

But when I add

\usepackage[utf8]{inputenc}
\usepackage[german]{babel}

to the preamble, it starts giving an error:

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

the same for russian. It is somehow related to the quotes in the array:

\def\names{{"1", "2"}}

I tried the tricks, shown here for the french, but they don't work.

share|improve this question
add comment

1 Answer 1

up vote 11 down vote accepted

The trick for French disables the shorthand ;, which isn't used with German, where the shorthand to be disabled is ".

However, the \tikzset{every picture/...} command should be given outside the picture, or it won't have effect.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}

\tikzset{
  every picture/.prefix style={
    execute at begin picture=\shorthandoff{"}
  }
}

\begin{document}

\begin{tikzpicture}
  \def\names{{"1", "2"}}
  \foreach \i in {0,1} {%
    \ifnum\i=0\relax
      \node (\i) [draw] {\pgfmathparse{\names[\i]}\pgfmathresult};
    \else
      \pgfmathparse{int(\i-1)}
      \node (\i) [draw,right= 1cm of \pgfmathresult]
            {\pgfmathparse{\names[\i]}\pgfmathresult};
      \draw[dotted] ($(\pgfmathresult.south east) !.5! (\i.south west)$)
            -- +(0,1cm);
  \fi
}
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.