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.

Possible Duplicate:
tikz declare function and babel french option

I'm working on a document requiring both tikz and [french]Babel.

There is a clash between [french]Babel, and TIKZ:

  • No problem if either one not loaded
  • No problem with the German or Italian languages
  • Partial problem with the Spanish language

What to do ?

%!TEX TS-program = pdflatex
\PassOptionsToPackage{table,x11names,svgnames}{xcolor}

% ..............................................
% Expected behavior for language selection: (see original text, below, from Daniel Flipo):
%
%    The last language loaded is the main one, used in the TOC and other lists. 
%    Hence, if English is the last one loaded, we should expect to read "Contents", "Chapter 1", etc. 
%           If French is the last one loaded, we should see "Table des matières", "Chapitre 1"
%
% Ref:  " Documentation sur le module frenchb de Babel Daniel Flipo Version 2.5j – 27 décembre 2012"
%       La dernière langue chargée (le français dans l’exemple ci-dessus) est active au début du document ; c’est la langue principale, celle qui régit la présentation générale (listes, notes de bas de page, retrait des premiers paragraphes) quelle que soit la langue courante.
% ..............................................

% ..........................................................................................
% ......LANGUAGES TESTS: ENGLISH, FRENCH, SPANISH, ITALIAN, GERMAN / BEGINNING..........
%
%................  ENGLISH ............WORKS FINE......WITH OR WITHOUT [english] BABEL..........
%
%  \documentclass[10pt,twoside,openright,usletter,english]{book} % 
%  \usepackage[english]{babel} 
%
%................  FRENCH ............CRASHES.........CRASHES ONLY IF [FRENCH]BABEL LOADED.........
%
% .....Weird error as a result of a clash between Tikz and Babel/French..........
% .....No problem with the English or German or italian languages, partial problem with Spanish
% .....==>> if Tikz NOT loaded, then Babel / French:   works well.
%
%   \documentclass[10pt,twoside,openright,usletter,english,french]{book} % CRASHES ONLY IF [FRENCH]BABEL LOADED: " ! Argument of \tikz@next has an extra }  "
%
%  \documentclass[10pt,twoside,openright,usletter,french,english]{book} % CRASHES ONLY IF [FRENCH]BABEL LOADED: " ! Argument of \tikz@next has an extra }  "
%
  \documentclass[10pt,twoside,openright,usletter,french]{book}  % CRASHES PARTIALLY (SCROLLED MODE WORKS, but English is first language in Contents / Chapter) when [FRENCH]BABEL NOT LOADED: " ! Package babel Error: You haven't loaded the option english yet."  .......  IF [ENGLISH] BABEL or [ENGLISH,FRENCH] BABEL LOADED, crashes: " ! Argument of \tikz@next has an extra }." ......... 
%
   \usepackage[english,french]{babel} 
%   \usepackage[french]{babel} 
%
%................  SPANISH ...............WORKS PARTIALLY..........................
%
%  \documentclass[10pt,twoside,openright,usletter,spanish]{book}  % CRASHES PARTIALLY (SCROLLED MODE WORKS) when [spanish]Babel not loaded: ! Package babel Error: You haven't loaded the option english yet.
%  \usepackage[spanish]{babel}   % CRASHES PARTIALLY (SCROLLED MODE WORKS): " Cap\'{\i }tulo 1. ! Missing \endcsname inserted. <to be read again>  "
%   \usepackage[spanish,english]{babel}  % WORKS FINE, BUT English first (Contents, Chapter)
%  \usepackage[english,spanish]{babel}  % WORKS FINE, BUT English first (Contents, Chapter)
%   
%
%................  ITALIAN .............WORKS FINE.........WITH OR WITHOUT [italian] BABEL........
%
%   \documentclass[10pt,twoside,openright,usletter,english,italian]{book}  % WORKS / italian=first language
%   \documentclass[10pt,twoside,openright,usletter,italian,english]{book}  % WORKS / italian=first language
%   \usepackage[italian]{babel} 
%
%................  GERMAN ............WORKS FINE.........WITH OR WITHOUT [italian] BABEL..........
%
%   \documentclass[10pt,twoside,openright,usletter,english,german]{book} % WORKS / German=first language
%   \documentclass[10pt,twoside,openright,usletter,german,english]{book}  % WORKS / English=first language
%   \usepackage[german]{babel} 
%
% ..........................................................................................
% ......LANGUAGES TESTS: ENGLISH, FRENCH, SPANISH, ITALIAN, GERMAN / END..........
% ..........................................................................................



\usepackage{lipsum}

    \usepackage{eso-pic}
    \usepackage{tikz}
    \usetikzlibrary{positioning}  
    \usetikzlibrary{shapes}

\usepackage{hyperref}


\hypersetup{colorlinks=true,
         breaklinks=true,
         linkcolor=magenta,   
         bookmarks=true,
          pageanchor=true}     


    % Dimensions of tabs
    % Bloc dimensions étiquettes verticales à droite
    \newlength\HauteurOngletDroite   
    \setlength\HauteurOngletDroite{\dimexpr\paperheight/8\relax} %  
    \newlength\LargeurOngletDroite
    \setlength\LargeurOngletDroite{\dimexpr\paperwidth/33\relax} % 
    \newlength\ProfondeurTexteOngletDroite   
    \setlength\ProfondeurTexteOngletDroite{\dimexpr\LargeurOngletDroite/2-1.5mm\relax}
    \newlength\xOngletDroite  
    \setlength\xOngletDroite{\dimexpr\paperwidth-(\LargeurOngletDroite*1/2)\relax}
    \newlength\yOngletZeroDroite
    \newlength\yOngletUnDroite
    \setlength\yOngletZeroDroite{\dimexpr\paperheight-(\HauteurOngletDroite*1/2)\relax} %
    \setlength\yOngletUnDroite{\dimexpr\paperheight-(\HauteurOngletDroite*3/2)\relax}

    % style of tabs
    \tikzset{OngletDroite/.style={
    align=center,text width=\HauteurOngletDroite,text height=\LargeurOngletDroite,text depth=\ProfondeurTexteOngletDroite,inner sep=0pt,thick,rectangle,rounded corners=5pt,rotate=270,font=\sffamily\normalsize
    }}  % 



    % Newcommand for "My" side tabs
    \newcommand{\MesOnglets}{%     
    \begin{tikzpicture}[remember picture,overlay]  
        \coordinate (PositionOngletDroiteZero) at (\xOngletDroite,\yOngletZeroDroite) ;  
        \coordinate (PositionOngletDroiteUn) at (\xOngletDroite,\yOngletUnDroite) ; 
    % 
    \node (OngletDroiteZero)   at (PositionOngletDroiteZero)  {\hyperlink{HyperTableOfcontents}{\tikz
    \node[OngletDroite,draw=purple,fill=gray!20,text=green]{TDM};}};  
    % 
    \node (OngletDroiteUn)   at (PositionOngletDroiteUn)  {\hyperlink{HyperChapitreUn}{\tikz
    \node[OngletDroite,draw=blue,shade,top color=red, bottom color=green,shading angle=-30,text=red] {Chapitre 1};}};  
    \end{tikzpicture}
    }%   


    \AddToShipoutPicture{  
    \MesOnglets     % side tabs shipped out to every page
    }%  




\begin{document}


    \frontmatter 
    \hypertarget{HyperTableOfcontents}{\tableofcontents}

    \mainmatter

    \cleardoublepage
    \hypertarget{HyperChapitreUn}{\chapter{Chapitre un}}
    \section{Section un Chapitre un}

    \lipsum
    \section{Section deux Chapitre un}
    \lipsum

    \lipsum
    \lipsum

    \cleardoublepage
    \chapter{Chapitre deux}
    \lipsum
    \section{Section un Chapitre deux}
    \lipsum
    \section{Section deux Chapitre deux}
        \lipsum
    \lipsum
    \lipsum



\end{document}
share|improve this question

marked as duplicate by egreg, Kurt, Speravir, Guido, Werner Jan 21 '13 at 2:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
This is a lot of code. In order to help people who'll help you, could you please remove everything from the code that's not related to your problem and add a little document, a so-called minimal working example (MWE), that people can copy and compile to reproduce your problem? Otherwise, your question might be in danger of being closed as too localized. –  doncherry Jan 20 '13 at 19:24
1  
Which is your version of tikz? Recent cvs ones have some improvements regarding active characters ;:!?. –  cjorssen Jan 20 '13 at 19:31
    
Related: tex.stackexchange.com/questions/86023/… –  egreg Jan 20 '13 at 21:02

1 Answer 1

up vote 0 down vote accepted

Sorry for the "lot of code", I'll remember that.

Thanks very much egreg for the link, and Daniel Flipo (email answer) who is the author of the documentation for Babel / French.

Tikz and Babel/French clash because of a different interpretation of ";"

There are several ways to fix that.

  • First one (simpler one):

    replace

    \newcommand{\MesOnglets}{% \begin{tikzpicture}[remember picture,overlay]

    with

    \newcommand{\MesOnglets}{% \begin{tikzpicture}[remember picture,overlay]\NoAutoSpacing %

  • Second one:

    replace

    \newcommand{\MesOnglets}{% \begin{tikzpicture}[remember picture,overlay]

    with

    \newcommand{\MesOnglets}{% \begin{tikzpicture}[remember picture,overlay]\shorthandoff{;} %

  • Third one:

    The etoolbox Package by Philipp Lehman provides a tool to localize within tikz the interpretation of ";" . For fixing every "tikzpicture" within the document, just add the two following lines, only for the French version:

    \usepackage{etoolbox} \AtBeginEnvironment{tikzpicture}{\shorthandoff{;}}

Here is my final code that works well:

%!TEX TS-program = pdflatex
\PassOptionsToPackage{table,x11names,svgnames}{xcolor}

%  Références:
%  http://tex.stackexchange.com/questions/29978/with-tipa-and-babels-ngerman-shorthandoff-in-a-macro
%  http://tex.stackexchange.com/questions/34670/babel-shorthand-doesnt-work-in-macros
%  http://tex.stackexchange.com/questions/86023/tikz-declare-function-and-babel-french-option
%
%   Solution de Daniel Flipo, auteur de la documentation Babel/français
%   C'est un problème bien connu de caractères « actifs » (le ; cette-fois). C'est traité dans la doc (section 5).
%   
%   Le plus simple est de remplacer
%      \newcommand{\MesOnglets}{%
%      \begin{tikzpicture}[remember picture,overlay]
%   par
%      \newcommand{\MesOnglets}{%
%      \begin{tikzpicture}[remember picture,overlay]\NoAutoSpacing % <=
%   ou seulement par
%      \newcommand{\MesOnglets}{%
%      \begin{tikzpicture}[remember picture,overlay]\shorthandoff{;} % <=


\documentclass[10pt,twoside,openright,usletter,french]{book}  
\usepackage{babel} % ordre de chargement tikz / babel ne change rien
\usepackage{lipsum}
\usepackage{eso-pic}
\usepackage{tikz}
\usetikzlibrary{positioning}  
\usetikzlibrary{shapes}



\usepackage{hyperref}


\hypersetup{colorlinks=true,
         breaklinks=true,
         linkcolor=magenta,   
         bookmarks=true,
          pageanchor=true}     

%---------

    % Bloc dimensions étiquettes verticales à droite
    \newlength\HauteurOngletDroite   
    \setlength\HauteurOngletDroite{\dimexpr\paperheight/8\relax} %  
    \newlength\LargeurOngletDroite
    \setlength\LargeurOngletDroite{\dimexpr\paperwidth/33\relax} % 
    \newlength\ProfondeurTexteOngletDroite   
    \setlength\ProfondeurTexteOngletDroite{\dimexpr\LargeurOngletDroite/2-1.5mm\relax}
    \newlength\xOngletDroite  
    \setlength\xOngletDroite{\dimexpr\paperwidth-(\LargeurOngletDroite*1/2)\relax}
    \newlength\yOngletZeroDroite
    \newlength\yOngletUnDroite
    \setlength\yOngletZeroDroite{\dimexpr\paperheight-(\HauteurOngletDroite*1/2)\relax} %
    \setlength\yOngletUnDroite{\dimexpr\paperheight-(\HauteurOngletDroite*3/2)\relax}

    % style of tabs
    \tikzset{OngletDroite/.style={
    align=center,text width=\HauteurOngletDroite,text height=\LargeurOngletDroite,text depth=\ProfondeurTexteOngletDroite,inner sep=0pt,thick,rectangle,rounded corners=5pt,rotate=270,font=\sffamily\normalsize
    }}  % 


    \newcommand{\MesOnglets}{%     
    \begin{tikzpicture}[remember picture,overlay]\NoAutoSpacing %  
        \coordinate (PositionOngletDroiteZero) at (\xOngletDroite,\yOngletZeroDroite) ;  
        \coordinate (PositionOngletDroiteUn) at (\xOngletDroite,\yOngletUnDroite) ; 
    % 
    \node (OngletDroiteZero)   at (PositionOngletDroiteZero)  {\hyperlink{HyperTableOfcontents}{\tikz
    \node[OngletDroite,draw=purple,fill=gray!20,text=green]{TDM};}};  
    % 
    \node (OngletDroiteUn)   at (PositionOngletDroiteUn)  {\hyperlink{HyperChapitreUn}{\tikz
    \node[OngletDroite,draw=blue,shade,top color=red, bottom color=green,shading angle=-30,text=red] {Chapitre 1};}};  
    \end{tikzpicture}
    }%   


    \AddToShipoutPicture{  
    \MesOnglets     % side tabs shipped out to every page
    }%  




    \begin{document}


    \frontmatter 
    \hypertarget{HyperTableOfcontents}{\tableofcontents}

    \mainmatter

    \cleardoublepage
    \hypertarget{HyperChapitreUn}{\chapter{Chapitre un}}
    \section{Section un Chapitre un}

    \lipsum
    \section{Section deux Chapitre un}
    \lipsum

    \lipsum
    \lipsum

    \cleardoublepage
    \chapter{Chapitre deux}
    \lipsum
    \section{Section un Chapitre deux}
    \lipsum
    \section{Section deux Chapitre deux}
        \lipsum
    \lipsum
    \lipsum
\end{document}
share|improve this answer
    
In Jake’s answer to the question linked by egreg (E. Gregorio) you can see, that there is no need for etoolbox here! And doncherry already asked kindly for making your examples to minimal ones. –  Speravir Jan 20 '13 at 23:57

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