1

I want to dimensioning a drawing with , this includes angles. I found this answer that worked pretty well for me, but when I include the babel package in my document, there were some problems, this is the code that works well (with some changes to the original code):

\documentclass{scrbook}
\usepackage{babel}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xparse}
\tikzset{%
    Cote node/.style={
        midway,
        fill=white,
        inner sep=1.5pt,
        outer sep=2pt
    },
    Cote arrow/.style={
        <->,
        >=latex,
        very thin
    }
}

\makeatletter \NewDocumentCommand{\Cote}{ s % dimensioning with arrows outside D<>{1.5pt} % line offset O{.75cm} % dimension offset m % first point m % second point m % label D<>{o} % () coordinates -> angle % h -> horizontal, % v -> vertical % or whatever -> oblique O{} % tikzset parameter }{

{\tikzset{#8}

\coordinate (@1) at #4 ;
\coordinate (@2) at #5 ;

\if #7H % dimension horizontal line
    \coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
    \coordinate (@5) at ($#5+(#3,0)$) ;
    \coordinate (@4) at ($#4+(#3,0)$) ;
\else
\if #7V % dimension vertical line
    \coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
    \coordinate (@5) at ($#5+(0,#3)$) ;
    \coordinate (@4) at ($#4+(0,#3)$) ;
\else
\if #7v % vertical dimension
    \coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
    \coordinate (@4) at (@0|-@1) ;
    \coordinate (@5) at (@0|-@2) ;
\else
\if #7h % horizontal dimension
    \coordinate (@0) at ($($#4!.5!#5$) + (0,#3)$) ;
    \coordinate (@4) at (@0-|@1) ;
    \coordinate (@5) at (@0-|@2) ;
\else % concave dimensioning
\ifnum\pdfstrcmp{\unexpanded\expandafter{\@car#7\@nil}}{(}=\z@
    \coordinate (@5) at ($#7!#3!#5$) ;
    \coordinate (@4) at ($#7!#3!#4$) ;
\else % oblique dimension
    \coordinate (@5) at ($#5!#3!90:#4$) ;
    \coordinate (@4) at ($#4!#3!-90:#5$) ;
\fi\fi\fi\fi\fi

\draw[very thin,shorten &gt;= #2,shorten &lt;= -2*#2] (@4) -- #4 ;
\draw[very thin,shorten &gt;= #2,shorten &lt;= -2*#2] (@5) -- #5 ;

\IfBooleanTF #1 {% with star
\draw[Cote arrow,-] (@4) -- (@5)
    node[Cote node] {#6\strut};
\draw[Cote arrow,&lt;-] (@4) -- ($(@4)!-6pt!(@5)$) ;
\draw[Cote arrow,&lt;-] (@5) -- ($(@5)!-6pt!(@4)$) ;
}{% without star
\ifnum\pdfstrcmp{\unexpanded\expandafter{\@car#7\@nil}}{(}=\z@
    \draw[Cote arrow] (@5) to[bend right]
        node[Cote node] {#6\strut} (@4) ;
\else
\draw[Cote arrow] (@4) -- (@5)
    node[Cote node] {#6\strut};
\fi
}}
}

\makeatother

\begin{document} \begin{tikzpicture} \small \draw[thick,blue,fill=blue!25] (0,1) coordinate (A) -- (3,1) coordinate (B) -- (5,2) coordinate (C) -- (5,4) coordinate (D) -- (3,4) coordinate (E) -- (2.5,3) coordinate (F) -- (2,4) coordinate (G) -- (0,4) coordinate (H) --cycle ;

\draw[red,fill=red!25] (2.5,3.9) circle (.39) ;

\Cote{(A)}{(B)}{1 m}

\Cote{(B)}{(C)}{2 m}[red]

\Cote[.3cm]{(B)}{(C)}{2}[%
    red,Cote node/.append style={sloped}]

\Cote{(B)}{(C)}{2 bis}&lt;h&gt;[Cote node/.append style={fill=blue!25}]

\Cote[.3cm]{(C)}{(D)}{3 bis}[%
        Cote node/.append style={rotate=90}]
\Cote[.7cm]{(C)}{(D)}{3}
\Cote[1.1cm]{(C)}{(D)}{3 ter}[%
            Cote node/.append style={right}]

\Cote[2cm]{(G)}{(E)}{45$^\circ$}&lt;(F)&gt;

\Cote*[1.2cm]{(2.11,3.9)}{(2.89,3.9)}{4}[%
    Cote node/.append style={fill=blue!25}]

\Cote[-2cm]{(A)}{(2.5,4.29)}{5}&lt;v&gt;

\end{tikzpicture}

\end{document}

this generates:

enter image description here

But when I change:

\usepackage{babel}

for:

\usepackage[spanish, es-nodecimaldot, es-tabla]{babel}

I get:

enter image description here

Why does this happen and how can I fix it?, I'm using pdflatex, thanks in advance.

4lrdyD
  • 181

1 Answers1

1

Add the TikZ library babel.

\documentclass{scrbook}
\usepackage[spanish, es-nodecimaldot, es-tabla]{babel}
\usepackage{tikz}
\usetikzlibrary{babel,calc} %<- added babel
\usepackage{xparse}
\tikzset{%
    Cote node/.style={
        midway,
        fill=white,
        inner sep=1.5pt,
        outer sep=2pt
    },
    Cote arrow/.style={
        <->,
        >=latex,
        very thin
    }
}

\makeatletter
\NewDocumentCommand{\Cote}{
    s       % dimensioning with arrows outside
    D<>{1.5pt} % line offset
    O{.75cm}    % dimension offset
    m       % first point
    m       % second point
    m       % label
    D<>{o}  % () coordinates -> angle
            % h -> horizontal,
            % v -> vertical
            % or whatever -> oblique
    O{}     % tikzset parameter
    }{

    {\tikzset{#8}

    \coordinate (@1) at #4 ;
    \coordinate (@2) at #5 ;

    \if #7H % dimension horizontal line
        \coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
        \coordinate (@5) at ($#5+(#3,0)$) ;
        \coordinate (@4) at ($#4+(#3,0)$) ;
    \else
    \if #7V % dimension vertical line
        \coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
        \coordinate (@5) at ($#5+(0,#3)$) ;
        \coordinate (@4) at ($#4+(0,#3)$) ;
    \else
    \if #7v % vertical dimension
        \coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
        \coordinate (@4) at (@0|-@1) ;
        \coordinate (@5) at (@0|-@2) ;
    \else
    \if #7h % horizontal dimension
        \coordinate (@0) at ($($#4!.5!#5$) + (0,#3)$) ;
        \coordinate (@4) at (@0-|@1) ;
        \coordinate (@5) at (@0-|@2) ;
    \else % concave dimensioning
    \ifnum\pdfstrcmp{\unexpanded\expandafter{\@car#7\@nil}}{(}=\z@
        \coordinate (@5) at ($#7!#3!#5$) ;
        \coordinate (@4) at ($#7!#3!#4$) ;
    \else % oblique dimension
        \coordinate (@5) at ($#5!#3!90:#4$) ;
        \coordinate (@4) at ($#4!#3!-90:#5$) ;
    \fi\fi\fi\fi\fi

    \draw[very thin,shorten >= #2,shorten <= -2*#2] (@4) -- #4 ;
    \draw[very thin,shorten >= #2,shorten <= -2*#2] (@5) -- #5 ;

    \IfBooleanTF #1 {% with star
    \draw[Cote arrow,-] (@4) -- (@5)
        node[Cote node] {#6\strut};
    \draw[Cote arrow,<-] (@4) -- ($(@4)!-6pt!(@5)$) ;
    \draw[Cote arrow,<-] (@5) -- ($(@5)!-6pt!(@4)$) ;
    }{% without star
    \ifnum\pdfstrcmp{\unexpanded\expandafter{\@car#7\@nil}}{(}=\z@
        \draw[Cote arrow] (@5) to[bend right]
            node[Cote node] {#6\strut} (@4) ;
    \else
    \draw[Cote arrow] (@4) -- (@5)
        node[Cote node] {#6\strut};
    \fi
    }}
    }

\makeatother

\begin{document}
    \begin{tikzpicture}
    \small
    \draw[thick,blue,fill=blue!25]
            (0,1) coordinate (A)
        --  (3,1) coordinate (B)
        --  (5,2) coordinate (C)
        --  (5,4) coordinate (D)
        --  (3,4) coordinate (E)
        --  (2.5,3) coordinate (F)
        --  (2,4) coordinate (G)
        --  (0,4) coordinate (H)
        --cycle ;

    \draw[red,fill=red!25] (2.5,3.9) circle (.39) ;

    \Cote{(A)}{(B)}{1 m}

    \Cote{(B)}{(C)}{2 m}[red]

    \Cote[.3cm]{(B)}{(C)}{2}[%
        red,Cote node/.append style={sloped}]

    \Cote{(B)}{(C)}{2 bis}<h>[Cote node/.append style={fill=blue!25}]

    \Cote[.3cm]{(C)}{(D)}{3 bis}[%
            Cote node/.append style={rotate=90}]
    \Cote[.7cm]{(C)}{(D)}{3}
    \Cote[1.1cm]{(C)}{(D)}{3 ter}[%
                Cote node/.append style={right}]

    \Cote[2cm]{(G)}{(E)}{45$^\circ$}<(F)>

    \Cote*[1.2cm]{(2.11,3.9)}{(2.89,3.9)}{4}[%
        Cote node/.append style={fill=blue!25}]

    \Cote[-2cm]{(A)}{(2.5,4.29)}{5}<v>

    \end{tikzpicture}
\end{document}

enter image description here