问题的解释(似乎)在texdoc tkz-euclide
中的「Part VIII. Working with style」
tkz...
使用的所有的样式调用的是储存在point style
/line style
/vector style
等pre-difined的样式中,因此直接修改tiikzpicture
的全局样式并不会影响这些被tkz...
调用的样式,所以下面的代码中第二个图会失效。
\documentclass[border=3pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments[thick](A,B)
\end{tikzpicture}
\begin{tikzpicture}[thick]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\begin{tikzpicture}[line style/.append style={line width=1pt}]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
% \tkzSetUpLine[line width=1pt]
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\end{document}
可以使用line style/.append style={line width=1pt}
来做合并式修改
顺便回答了评论里的问题,下面才是本问题的关键:
在texdoc tkz-euclide
的文档中的sec 40.1. Use of \tkzSetUpLine
介绍了:
% \tkzSetUpLine[line width=1pt]
如下的另一份代码:
\documentclass[border=3pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments[thick](A,B)
\end{tikzpicture}
\begin{tikzpicture}[thick]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\begin{tikzpicture}[line style/.append style={line width=1pt}]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\tkzSetUpLine[line width=1pt]
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\end{document}
将会得到一个向右平移的神必bounding box...
为什么设置了\tkzSetUpLine[line width=1pt]
会导致这一偏移呢?
如果我显式添加tikz
选项给standalone
或者使用multi={tikzpicture}
,则不会有此问题:
\documentclass[
border=3pt,
% tikz,
multi={tikzpicture}
]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments[thick](A,B)
\end{tikzpicture}
\begin{tikzpicture}[thick]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\begin{tikzpicture}[line style/.append style={line width=1pt}]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\tkzSetUpLine[line width=1pt]
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\end{document}
可能需要看一下 \tkzSetUpLine
的定义, 当命令结束并且换行时, 应当添加注释符号, 否则可能产生空格, 这应该是 TeX 的特性. 也需要查看主命令内部所调用的命令的定义代码是否出现这种情况, 当出现多层次调用时, 需要检查的代码就多了.
\documentclass[border=3pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\makeatletter
\def\tkzSetUpLine{\pgfutil@ifnextchar[{\tkz@SetUpLine}{\tkz@SetUpLine[]}}
\def\tkz@SetUpLine[#1]{%
\pgfkeys{%
tkzsuline/.cd,
line width = \tkz@euc@linewidth,
color = \tkz@euc@linecolor,
style = \tkz@euc@linestyle,
% add = {\tkz@euc@lineleft} and {\tkz@euc@lineright},
}%
\pgfqkeys{/tkzsuline}{#1}%
\tikzset{%
line style/.append style ={%
line width = \tkz@line@width,
color = \tkz@line@color,
style = \tkz@line@style,
% add = {\tkz@line@left} and {\tkz@line@right},
line cap = round,
#1}
}%
}%
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments[thick](A,B)
\end{tikzpicture}
\begin{tikzpicture}[thick]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\begin{tikzpicture}[line style/.append style={line width=1pt}]
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\tkzSetUpLine[line width=1pt]%
\tkzSetUpLine[line width=1pt]%
\tkzSetUpLine[line width=1pt]%
\begin{tikzpicture}
\tkzDefPoints{0/0/A,1/1/B}
\tkzDrawSegments(A,B)
\end{tikzpicture}
\end{document}
在 tikzpicure
环境内部, 文本字符被设置为 \nullfont
, 一般没有这个问题.
tkz-euclide 包的主要优势在于提供了一些计算工具, 不在于设置样式. 我倾向于只用这个包做计算.
我是偶然发现的这个神秘现象😀
确实如此:
嗯忽然觉得这个问题的意义不是非常大...所以也不太需要费心检查了...