2

Consider the following MWE, compiled with xelatex

\documentclass{article}
\usepackage{fontspec}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \tikzset{boite/.style={draw,text width=14em,text badly centered}};
  \tikzset{liaison/.style={
        ->,thick,>=latex
    }};
  \node[boite]{foo};
\end{tikzpicture}
\end{document}

If I read this answer https://tex.stackexchange.com/a/326089/7712 we always need a semicolon after a tikzcommands;

BUT in my case I get Missing character: There is no ; ("3B) in font nullfont! in the log. It if delete the semicolons after tikzset, I don't get anymore.

Where is the bug ? In my code? In fontspec? In tikz? In the answer ?

6
  • 1
    We need a semicolon at the end of a path. Commented Dec 6, 2023 at 9:01
  • See section "Syntax for Path Specifications" in the pgf manual (p. 153, v.3.1.10). Commented Dec 6, 2023 at 9:04
  • All and only paths are terminated with a ;. (This includes for example \node because it's just a shortcut to \path node.) You don't need a ; after everything else, certainly not after \tikzset{…}. Various packages/libraries may define additional macros/constructs that also expect a ; at the end (e.g. \calendar from the calendar library). This may also true for external additions to TikZ. Commented Dec 6, 2023 at 9:21
  • So the answer on tex.stackexchange.com/a/326089/7712 is false :)
    – Maïeul
    Commented Dec 6, 2023 at 9:22
  • It is not false per sé, just a bit imprecise. The answer probably doesn't consider \tikzset to be a "TikZ command" as such, because it does not draw anything. In most situations you would also put \tikzset outside of \begin{tikzpicture}\end{tikzpicture} (that would also be advisable in your example code here), reinforcing the notion that it is not part of the drawing and therefore does not need semicolons. However I agree that the linked answer as it is should be clarified as it currently is somewhat misleading.
    – Marijn
    Commented Dec 6, 2023 at 15:32

2 Answers 2

4

You don't need multiple \tikzset commands and they shouldn't be ended by ; anyway.

Rather, define the styles in the optional argument to tikzpicture (or in the preamble with \tikzset.

\documentclass{article}
\usepackage{fontspec}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[
  boite/.style={draw,text width=14em,text badly centered},
  liaison/.style={->,thick,>=latex},
]
\node[boite]{foo};
\end{tikzpicture}

\end{document}
1

ONLY to confirm Qrrbrbirlbel comment, deleting or commenting out the semicola ; in the non-path statements compiles fine with XeLaTeX.

result

\documentclass{article}
\usepackage{fontspec}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \tikzset{boite/.style={draw,text width=14em,text badly centered}}%;
  \tikzset{liaison/.style={
        ->,thick,>=latex
    }}%;
  \node[boite]{foo};
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .