我有以下图片
这是用以下代码创建的:
\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\begin{document}
\usetkzobj{all}
\begin{tikzpicture}
\tkzSetUpPoint[shape=circle,size=10,color=black,fill=black]
\tkzSetUpLine[line width=1]
\tkzDefPoints{0/0/A, 3/0/B', 2/2/C, 4/4/C'}
\tkzDefLine[parallel=through C](B',C') \tkzGetPoint{Phelper}
\tkzInterLL(A,B')(C,Phelper) \tkzGetPoint{B}
\tkzDrawLine[add=0 and 0.2](A,B')
\tkzDrawLine[add=0 and 0.2](A,C')
\tkzDrawSegment(B',C')
\node at ($(A)+(-0.1,-0.2)$) {$A$};
\node at ($(B')+(0.2,-0.2)$) {$B'$};
\node at ($(C')+(0,0.4)$) {$C'$};
\node at ($(B)+(0.2,-0.2)$) {$B$};
\node at ($(C)+(0.28,0.5)$) {$C$};
\tkzDrawPolygon[ultra thick,color=blue,fill=blue!20](A,B',C')
\tkzDrawPolygon[line width=0.3pt,color=red,fill=red!20](A,B,C)
\tkzDrawPoints(A,B',C',B,C)
\tkzLabelSegment[below,red](A,B){$c$}
\tkzLabelSegment[left,red](A,C){$b$}
\tkzLabelSegment[right,red](B,C){$a$}
\tkzLabelSegment[below,blue,pos=0.8](A,B'){$c'$}
\tkzLabelSegment[left,blue,pos=0.8](A,C'){$b'$}
\tkzLabelSegment[right,blue](B',C'){$a'$}
\end{tikzpicture}
\end{document}
您可能会注意到,上面的空间C'
比必要的大。这是因为Phelper
。我需要Phelper
构造,但它不应该以任何方式影响图像大小。我试图更Phelper
接近C
,但似乎不可能。
我怎样才能阻止已定义但不可见的点影响图像大小?
请注意:我将这样的代码包装在图中。因此,像上面这样的图像只是整个文档的一部分。因此,使用它并standalone
不能解决我的问题。
答案1
将键添加/tikz/overlay
到定义坐标的命令Phelpher
(实际上是\tkzDefLine
命令)。此键表示“计算边界框时不要使用此构造。”。这是pgfinterruptboundingbox
Torbjørn 在他的评论中提到的单键版本。由于tkz
宏使用自己的键,并且不会将未知键传递给 tikz,因此您需要前缀/tikz/
。
\documentclass[varwidth=true, border=2pt]{standalone}
%\url{http://tex.stackexchange.com/q/155343/86}
\usepackage{tikz}
\usepackage{tkz-euclide}
\begin{document}
\usetkzobj{all}
\begin{tikzpicture}
\tkzSetUpPoint[shape=circle,size=10,color=black,fill=black]
\tkzSetUpLine[line width=1]
\tkzDefPoints{0/0/A, 3/0/B', 2/2/C, 4/4/C'}
\tkzDefLine[parallel=through C,/tikz/overlay](B',C') \tkzGetPoint{Phelper}
\tkzInterLL(A,B')(C,Phelper) \tkzGetPoint{B}
\tkzDrawLine[add=0 and 0.2](A,B')
\tkzDrawLine[add=0 and 0.2](A,C')
\tkzDrawSegment(B',C')
\node at ($(A)+(-0.1,-0.2)$) {$A$};
\node at ($(B')+(0.2,-0.2)$) {$B'$};
\node at ($(C')+(0,0.4)$) {$C'$};
\node at ($(B)+(0.2,-0.2)$) {$B$};
\node at ($(C)+(0.28,0.5)$) {$C$};
\tkzDrawPolygon[ultra thick,color=blue,fill=blue!20](A,B',C')
\tkzDrawPolygon[line width=0.3pt,color=red,fill=red!20](A,B,C)
\tkzDrawPoints(A,B',C',B,C)
\tkzLabelSegment[below,red](A,B){$c$}
\tkzLabelSegment[left,red](A,C){$b$}
\tkzLabelSegment[right,red](B,C){$a$}
\tkzLabelSegment[below,blue,pos=0.8](A,B'){$c'$}
\tkzLabelSegment[left,blue,pos=0.8](A,C'){$b'$}
\tkzLabelSegment[right,blue](B',C'){$a'$}
\end{tikzpicture}
\end{document}