1

Here is an example with the angle option of the Straight Barb arrow using the colon character :

\tikzset{>={Straight Barb[angle=60:2pt 3]}}

The error is

! Paragraph ended before \pgfarrowsfourparameters@ was complete.

\documentclass[french]{article}
\usepackage{babel,tikz}
\usetikzlibrary{arrows.meta,babel}
\begin{document}

% inside the environment document, babel library doesnt work
\tikzset{>={Straight Barb[angle=60:2pt 3]}} 

\begin{tikzpicture}
\tikzset{>={Straight Barb[angle=60:2pt 3]}}
\draw[<->](0,0)--(2,0);

\end{tikzpicture}
\end{document}
Faheem Mitha
  • 7,778
AndréC
  • 24,137
  • Of course not, I took the trouble to write a minimal example and you still have to look for problems where there are none. When the document is composed of several pages and several tikzpicture environments, it is better to assign the arrows globally and not locally. – AndréC Jun 10 '19 at 17:59

1 Answers1

3

When \tikzset is located in the preamble, the TikZ babel library works.

\documentclass[french]{article}
\usepackage{babel,tikz}
\usetikzlibrary{arrows.meta,babel}
% In the preamble, babel library work
\tikzset{>={Straight Barb[angle=60:2pt 3]}} 

\begin{document}

\begin{tikzpicture}
\draw[<->](0,0)--(2,0);
\end{tikzpicture}

\end{document}

Inside the document environment, it is necessary to place \tikzset between the \shorthandoff{:} and \shorthandon{:}

\documentclass[french]{article}
\usepackage{babel,tikz}
\usetikzlibrary{arrows.meta,babel}

\begin{document}
% Between the command \shorthandoff{:} and \shorthandon{:}, no more problems
\shorthandoff{:}
\tikzset{>={Straight Barb[angle=60:2pt 3]}} 
\shorthandon{:}

\begin{tikzpicture}
\tikzset{>={Straight Barb[angle=60:2pt 3]}}
\draw[<->](0,0)--(2,0);
\end{tikzpicture}

\end{document}

In both cases, we get:

screenshot

egreg
  • 1,121,712
AndréC
  • 24,137
  • Yes, nice. In other languages (looking at you, spanish) you need \deactivatequoting. With the modern utf8 setup all these tricks are not so useful anymore... It would be nice if babel had a option with "stop any catcode game"... – Rmano Jun 10 '19 at 21:15
  • Since March 25, 2018, utf8 is the default encoding for LaTeX, see: utf8 as standard Nevertheless, I have this problem with Babel. It would indeed be nice if the \tikzset command or the babel library could be fixed. – AndréC Jun 10 '19 at 21:33
  • 1
    Regarding the sentence “When \tikzset is located in the preamble, the TikZ babel library works.”: as far as I know, babel-french doesn't make the characters :;!? active before \begin{document}. So, saying that the “TikZ babel library works” in this case might be a bit far-fetched... – frougon Jun 10 '19 at 22:07
  • @frougon Indeed, the more I think about this problem, the less I can understand its cause. Is it the command \tikzset? the babel library? or is it the document environment? – AndréC Jun 11 '19 at 04:21
  • 1
    @AndréC TikZ has to parse input where some characters (here ,:) aren't the same from TeX's point of view for everyone (depending on use of the optional use of babel and the chosen language). I don't know the implementation, but this is not an easy situation. Back in the days, you couldn't even use \label{fig:foobar} in LaTeX with an active : character... Why don't you use \tikzset in the preamble if it works there? – frougon Jun 11 '19 at 06:24
  • 1
    @Rmano Do you mean shorthands=off? :-) – Javier Bezos Jun 11 '19 at 12:01
  • @frougon According to page 35 of the 3.1.3 manual , the command \tikzset must be at the beginning of the document and in this case, there is a problem. Nevertheless, on page 70, we learn that this command \tikzset can be placed in the preamble. I posted this question because it took me several hours to identify the cause of the error. And I indicate in the solution, two different ways to solve this problem including placement in the preamble. – AndréC Jun 11 '19 at 13:40
  • @AndréC One can probably agree that “beginning of the document” doesn't necessarily mean “beginning of the document environment”. :-) – frougon Jun 11 '19 at 14:11
  • @JavierBezos, yes, it works, but if babel has been Requireed in a class, I have to use \deactivatequoting... – Rmano Jun 11 '19 at 16:28
  • @frougon If this were the case, it would not be specified in the preamble on page 70. – AndréC Jun 11 '19 at 17:41
  • 1
    @AndréC Huh? You said yourself in your own answer that there is no problem when \tikzset is used in the preamble. Therefore, the sentence on page 70 (“Ilka has moved the style definition to the preamble by saying \tikzset{terminal/.style=...} (...)”) gives working advice according to your own sayings, as opposed to using \tikzset in the document environment outside any tikzpicture. – frougon Jun 11 '19 at 18:22
  • @frougon I don't understand you. If the manual said it was absolutely necessary to place \tikzset in the preamble, it would be written in plain language. The examples in the manual place \tikzset both in the document environment and within the tikzpicture environment itself (see for example page 143). In other words, there is nothing in the manual to indicate where the \tikzset command should be located.

    Translated with www.DeepL.com/Translator

    – AndréC Jun 11 '19 at 19:52
  • 1
    @AndréC You still haven't pointed any place in the manual suggesting to put \tikzset in a place where it might cause problems. On page 143, \tikzset is used inside the \tikzpicture environment; it works quite fine there even with [french]{babel}, as shown by this example: \documentclass[french]{article} \usepackage{babel,tikz} \usetikzlibrary{arrows.meta,babel} \begin{document} \begin{tikzpicture} \tikzset{>={Straight Barb[angle=60:2pt 3]}} \draw[<->](0,0)--(2,0); \end{tikzpicture} \end{document}. – frougon Jun 11 '19 at 21:14
  • @frougon I don't understand your problem. – AndréC Jun 11 '19 at 21:38
  • 1
    @AndréC I have no problem. I didn't ask the question on this page. Never mind. – frougon Jun 11 '19 at 21:42
  • 1
    @Rmano Usually \PassOptionsToPackage{shorthands=off}{babel} before loading the class does the trick. – Javier Bezos Jun 12 '19 at 14:27