在下面的 MWE 中,除非图片 (1) 中\usetikzlibrary{babel}
加载了 ,否则会标记编译错误。但是,图片 (2) 和图片 (3) 中的加载都标记编译错误。奇怪的是,所有其他宏似乎都运行良好,例如,等等。有没有办法摆脱这种困境?pic ["$\alpha$",draw, fill=yellow]{angle= A--B--C}
!Missing \endcsname inserted
\usetikzlibrary{babel}
\tkzRep[color=red, ynorm=2]
\tkzDrawLine(A,B)
!Undefined control sequence.\tkz
\tkz
\tkzDrawPoints
\tkzDrawSegment
\documentclass{article}
% RN. 20 October 2017
\usepackage[utf8]{inputenc}
\usepackage[greek,ngerman,french,english]{babel}
\usepackage{tikz}
\usepackage{tkz-base,tkz-euclide}
\usetikzlibrary{angles,quotes}
\usetikzlibrary{babel}
\begin{document}
(1) Till Tantau:\\
\begin{tikzpicture}
\draw (3,0) coordinate (A)
-- (0,1) coordinate (B)
-- (1,2) coordinate (C)
pic ["$\alpha$",draw, fill=yellow]{angle= A--B--C}
;
\end{tikzpicture}
(2) Alain Matthes: tkz-base\\
\begin{tikzpicture}
\tikzset{xaxe style/.style={-}}
\tikzset{yaxe style/.style={-}}
\tkzInit[xmax=4,ymax=4]
\tkzGrid
\tkzDrawX
\tkzDrawY
% \tkzRep[color=red, ynorm=2]
\end{tikzpicture}
(3) Alain Matthes: tkz-euclide\\
\begin{tikzpicture}
\tkzDefPoint(2,3){A}
\tkzDefShiftPointCoord[2,3](30:4){B}
\tkzDefBarycentricPoint(A=1,B=2)
\tkzGetPoint{I}
\tkzDrawPoints(A,B,I)
% \tkzDrawLine(A,B)
\tkzLabelPoints(A,B,I)
\end{tikzpicture}
\end{document}
答案1
图书馆babel
所做的不过是
\tikzset{
handle active characters in code,
handle active characters in nodes
}
它的作用是将各种字符的字符代码改回其默认设置。我无法提供确切的细节,但看到错误说
! Undefined control sequence.
l.1 \tkz
@Rep@ylabel
似乎\tkz@Rep@ylabel
在某个地方遇到了宏,而该地方的字符代码@
已设置为其他(我猜测),因此无法在宏中使用它。
无论如何,您可以通过本地设置来解决这个问题/tikz/handle active characters in nodes=false
IE
\tkzRep[/tikz/handle active characters in nodes=false,color=red, ynorm=2]
\tkzDrawLine[/tikz/handle active characters in nodes=false](A,B)
\documentclass{article}
% RN. 20 October 2017
\usepackage[utf8]{inputenc}
\usepackage[greek,ngerman,french,english]{babel}
\usepackage{tikz}
\usepackage{tkz-base,tkz-euclide}
\usetikzlibrary{angles,quotes}
\usetikzlibrary{babel}
\begin{document}
(1) Till Tantau:\\
\begin{tikzpicture}
\draw (3,0) coordinate (A)
-- (0,1) coordinate (B)
-- (1,2) coordinate (C)
pic ["$\alpha$",draw, fill=yellow]{angle= A--B--C}
;
\end{tikzpicture}
(2) Alain Matthes: tkz-base\\
\begin{tikzpicture}
\tikzset{xaxe style/.style={-}}
\tikzset{yaxe style/.style={-}}
\tkzInit[xmax=4,ymax=4]
\tkzGrid
\tkzDrawX
\tkzDrawY
\tkzRep[/tikz/handle active characters in nodes=false,color=red, ynorm=2]
\end{tikzpicture}
(3) Alain Matthes: tkz-euclide\\
\begin{tikzpicture}
\tkzDefPoint(2,3){A}
\tkzDefShiftPointCoord[2,3](30:4){B}
\tkzDefBarycentricPoint(A=1,B=2)
\tkzGetPoint{I}
\tkzDrawPoints(A,B,I)
\tkzDrawLine[/tikz/handle active characters in nodes=false](A,B)
\tkzLabelPoints(A,B,I)
\end{tikzpicture}
\end{document}