tikz:tikzpicture 上有太多空白

tikz:tikzpicture 上有太多空白

響球。

我不明白为什么图像上有太多空白。有什么建议可以解决它吗?谢谢

\documentclass[]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\usetikzlibrary{calc,patterns,angles,quotes,arrows,intersections,through,backgrounds,arrows.meta,positioning,math,babel}
\begin{document}
\fbox{
    \begin{tikzpicture}
    \tkzInit\tkzClip[space = 1]
    \tkzPoint[pos = left](0,0){A}
    \tkzPoint[pos = above](4,6){B}
    \tkzPoint[pos = right](10,0){C}
    \tkzDrawPolygon(A,B,C)
    \tkzInCenter(A,B,C) \tkzGetPoint{I}
    \tkzDefPointBy[projection=onto B--C](I)
    \tkzGetPoint{H}
    \tkzDefPointBy[projection=onto A--C](I)
    \tkzGetPoint{K}
    \tkzDefPointBy[projection=onto A--B](I)
    \tkzGetPoint{L}
    \tkzDrawSegments[dotted](I,L I,H I,K)
    \tkzDrawSegments[dashed](I,A I,B I,C)
    \tkzDrawCircle(I,H)
    \tkzMarkRightAngles%
    [fill=gray!10,](I,L,B B,H,I C,K,I)
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = I--B--H};   
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = L--B--I};   
    \tkzLabelAngle[pos=0.7,](H,B,I){$\alpha$};
    \tkzLabelAngle[pos=0.7,](L,B,I){$\alpha$};

    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = K--A--I};   
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = I--A--L};   
    \tkzLabelAngle[pos=0.7,](L,A,I){$\beta$};
    \tkzLabelAngle[pos=0.7,](I,A,K){$\beta$};


    \pic[draw=black,text=black,-,angle eccentricity=0.1,angle radius=0.7cm]{angle = H--C--I};   
    \pic[draw=black,text=black,-,angle eccentricity=0.1,angle radius=0.7cm]{angle = I--C--K};   
    \tkzLabelAngle[pos=1,](H,C,I){$\gamma$};
    \tkzLabelAngle[pos=1,](I,C,K){$\gamma$};
    \end{tikzpicture}
}
\end{document}

上述代码的输出

答案1

我没有尝试追踪问题的确切根源,但这是一个已知问题,即边界框不仅考虑所有可见对象,还考虑用于计算路径等的坐标。我认为这也可能是这里的问题。

作为一种解决方法,移除\tkzInit\tkzClip[space = 1]并包装不应影响pgfinterruptboundingbox环境中边界框的所有内容。

如果您希望边界框比三角形稍大,您可以\path ([xshift=-1cm,yshift=-1cm]current bounding box.south west) ([xshift=1cm,yshift=1cm]current bounding box.north east);按照@marmot 在下面的评论中的建议进行添加。

\documentclass[]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\usetikzlibrary{calc,patterns,angles,quotes,arrows,intersections,through,backgrounds,arrows.meta,positioning,math,babel}
\pgfplotsset{compat=1.16}
\begin{document}
\fbox{
    \begin{tikzpicture}
%    \tkzInit\tkzClip[space = 1]
    \tkzPoint[pos = left](0,0){A}
    \tkzPoint[pos = above](4,6){B}
    \tkzPoint[pos = right](10,0){C}
    \tkzDrawPolygon(A,B,C)
    \begin{pgfinterruptboundingbox}
    \tkzInCenter(A,B,C) \tkzGetPoint{I}
    \tkzDefPointBy[projection=onto B--C](I)
    \tkzGetPoint{H}
    \tkzDefPointBy[projection=onto A--C](I)
    \tkzGetPoint{K}
    \tkzDefPointBy[projection=onto A--B](I)
    \tkzGetPoint{L}
    \tkzDrawSegments[dotted](I,L I,H I,K)
    \tkzDrawSegments[dashed](I,A I,B I,C)
    \tkzDrawCircle(I,H)
    \tkzMarkRightAngles%
    [fill=gray!10,](I,L,B B,H,I C,K,I)
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = I--B--H};   
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = L--B--I};   
    \tkzLabelAngle[pos=0.7,](H,B,I){$\alpha$};
    \tkzLabelAngle[pos=0.7,](L,B,I){$\alpha$};

    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = K--A--I};   
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = I--A--L};   
    \tkzLabelAngle[pos=0.7,](L,A,I){$\beta$};
    \tkzLabelAngle[pos=0.7,](I,A,K){$\beta$};


    \pic[draw=black,text=black,-,angle eccentricity=0.1,angle radius=0.7cm]{angle = H--C--I};   
    \pic[draw=black,text=black,-,angle eccentricity=0.1,angle radius=0.7cm]{angle = I--C--K};   
    \tkzLabelAngle[pos=1,](H,C,I){$\gamma$};
    \tkzLabelAngle[pos=1,](I,C,K){$\gamma$};
    \end{pgfinterruptboundingbox}
    \path ([xshift=-1cm,yshift=-1cm]current bounding box.south west) ([xshift=1cm,yshift=1cm]current bounding box.north east);
    \end{tikzpicture}
}
\end{document}

在此处输入图片描述

答案2

除了@samcarter 给出的解决方案之外,用矩形框住图形就可以了,\draw(-1,-1)rectangle(11,7);而无需使用\fbox来解决这个问题。

编辑:非常感谢 marmot,他发现了我没有看到的错误!

\documentclass[]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\usetikzlibrary{calc,patterns,angles,quotes,arrows,intersections,through,backgrounds,arrows.meta,positioning,math,babel}
\begin{document}
%\fbox{
    \begin{tikzpicture}
    \tkzInit[xmax=10,ymax=6]
    \tkzClip[space = 1]
    \draw(-1,-1)rectangle(11,7);
    \tkzPoint[pos = left](0,0){A}
    \tkzPoint[pos = above](4,6){B}
    \tkzPoint[pos = right](10,0){C}
    \tkzDrawPolygon(A,B,C)
    %\begin{pgfinterruptboundingbox}
    \tkzInCenter(A,B,C) \tkzGetPoint{I}
    \tkzDefPointBy[projection=onto B--C](I)
    \tkzGetPoint{H}
    \tkzDefPointBy[projection=onto A--C](I)
    \tkzGetPoint{K}
    \tkzDefPointBy[projection=onto A--B](I)
    \tkzGetPoint{L}
    \tkzDrawSegments[dotted](I,L I,H I,K)
    \tkzDrawSegments[dashed](I,A I,B I,C)
    \tkzDrawCircle(I,H)
    \tkzMarkRightAngles%
    [fill=gray!10,](I,L,B B,H,I C,K,I)
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = I--B--H};   
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = L--B--I};   
    \tkzLabelAngle[pos=0.7,](H,B,I){$\alpha$};
    \tkzLabelAngle[pos=0.7,](L,B,I){$\alpha$};

    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = K--A--I};   
    \pic[draw=black,text=black,-,angle eccentricity=0.7,angle radius=0.5cm]{angle = I--A--L};   
    \tkzLabelAngle[pos=0.7,](L,A,I){$\beta$};
    \tkzLabelAngle[pos=0.7,](I,A,K){$\beta$};


    \pic[draw=black,text=black,-,angle eccentricity=0.1,angle radius=0.7cm]{angle = H--C--I};   
    \pic[draw=black,text=black,-,angle eccentricity=0.1,angle radius=0.7cm]{angle = I--C--K};   
    \tkzLabelAngle[pos=1,](H,C,I){$\gamma$};
    \tkzLabelAngle[pos=1,](I,C,K){$\gamma$};
    %\end{pgfinterruptboundingbox}
    \end{tikzpicture}
%}
\end{document}

欧几里得

答案3

使用 tkz-euclide v2.42b (beta)这里

\documentclass{standalone} 
\usepackage{tkz-euclide} 

\begin{document}  

  \begin{tikzpicture}[scale=2,trim left]
      \tkzInit[xmin=-1,xmax=9,ymin=-1,ymax=9]
      \tkzDefPoints{% x   y   name
                     0    /0    /A,
                     6    /0    /B,
                     0.8  /4    /C}
 \tkzDefIntouchTriangle[name=x](A,B,C){a,b,c}
 \tkzInCenter(A,B,C)\tkzGetPoint{I}

 \tkzDrawPolygon[red](A,B,C)
 \tkzDrawPolygon[blue](xa,xb,xc)
 \tkzDrawPoints[red](A,B,C)
 \tkzDrawPoints[blue](xa,xb,xc)
 \tkzDrawCircle[in](A,B,C)

 \tkzLabelPoints[red](A,B,C)
 \tkzLabelPoints[blue](xa,xb,xc)

 \tkzDrawPoint(I)
 \tkzDrawSegments[dashed](I,A I,B I,C I,xa I,xb I,xc)
 \tkzMarkRightAngles[size=.1,fill=gray!50,opacity=.5](I,xc,B I,xa,C I,xb,C)
\end{tikzpicture}    


\end{document}

在此处输入图片描述

相关内容