我想用蒂克兹,这包括角度。我发现这个回答对我来说效果很好,但是当我在文档中包含 babel 包时,出现了一些问题,这是运行良好的代码(对原来的代码):
\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 >= #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}
这将生成:
但是当我改变时:
\usepackage{babel}
为了:
\usepackage[spanish, es-nodecimaldot, es-tabla]{babel}
我得到:
为什么会发生这种情况?我该如何解决?我正在使用 pdflatex,提前谢谢您。
答案1
添加 Ti钾Z 库 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}