为什么“\tikzpicture”会移到文档之外?

为什么“\tikzpicture”会移到文档之外?

一切正常,直到我尝试绘制角度 alpha、beta 和 gamma。通过添加\tkzMarkAngle我的草图跳转到第二侧并被吞没到一半,如下面的屏幕截图所示。我看不出问题所在,我遗漏了什么?

\documentclass[11pt,a4paper]{article} % Defines the document as an article
\usepackage{tikz}                     % Graphic drawing library
\usepackage{tkz-euclide}              % Needed for "\usetkzobj{all}"
\usetkzobj{all}                       % Needed for "tkzMarkAngle" (tikz)
\begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tikzpicture}[xscale=0.5, yscale=0.5]
% DEFINE_MAIN_FRAME_COORDINATES ------------------------------------------------
  \coordinate[label=below:$A1$] (A1) at (0,0);
  \coordinate[label=above:$B1$] (B1) at (0,30);
  \coordinate[label=right:$C1$](C1) at (8,20.4);
% DRAW_MAIN_FRAME --------------------------------------------------------------
  \draw[line width=2pt][-] (C1) -- (B1) node [pos=0.5, right] {$a_1$};
  \draw[line width=2pt][-] (B1) -- (A1) node [pos=0.5, left]  {$c_1$};
  \draw[line width=2pt][-] (A1) -- (C1) node [pos=0.5, right] {$b_1$};
  \draw[dashed][-] (0,20.4) -- (C1) node [pos=0.5, above] {$h$};
% DRAW_ANGLES ------------------------------------------------------------------
  % alpha
  \tkzMarkAngle[fill=orange, size=4, opacity=0.4](C1,A1,B1)
  \tkzLabelAngle[pos=3](C1,A1,B1){$\alpha$}
  % beta
  \tkzMarkAngle[fill=orange, size=3, opacity=0.4](A1,B1,C1)
  \tkzLabelAngle[pos=2](A1,B1,C1){$\beta$}
  % gamma
  \tkzMarkAngle[fill=orange, size=2, opacity=0.4](B1,C1,A1)
  \tkzLabelAngle[pos=-1](B1,C1,A1){$\gamma$}
\end{tikzpicture}

\end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


结果输出

在此处输入图片描述

我感谢任何帮助、链接、参考和提示!

答案1

0.5由于尺寸对于 A4 纸来说太大,请按比例缩放图形。此外,使用angles,quotes库可以使绘制角度变得更容易。

\documentclass[11pt,a4paper]{article} % Defines the document as an article
\usepackage{tikz}                     % Graphic drawing library
%\usepackage{tkz-euclide}              % Needed for "\usetkzobj{all}"
%\usetkzobj{all}                       % Needed for "tkzMarkAngle" (tikz)
\usetikzlibrary{angles,quotes}
\begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{figure}\centering
\begin{tikzpicture}[scale=.5]
% DEFINE_MAIN_FRAME_COORDINATES ------------------------------------------------
  \coordinate[label=below:$A1$] (A1) at (0,0);
  \coordinate[label=above:$B1$] (B1) at (0,30);
  \coordinate[label=right:$C1$] (C1) at (8,20.4);
% DRAW_MAIN_FRAME --------------------------------------------------------------
  \draw[line width=2pt] (C1) -- (B1) node [pos=0.5, right] {$a_1$}
                             -- (A1) node [pos=0.5, left]  {$c_1$}
                             -- (C1) node [pos=0.5, right] {$b_1$}
                             -- cycle;
  \draw[dashed] (0,20.4) -- (C1) node [pos=0.5, above] {$h$};
% DRAW_ANGLES ------------------------------------------------------------------
  % alpha
  \draw pic[draw,fill=orange!50,angle radius=2cm,"$\alpha$"] {angle=C1--A1--B1};
  % beta
  \draw pic[draw,fill=orange!50,angle radius=2cm,"$\beta$"] {angle=A1--B1--C1};
  % gamma
  \draw pic[draw,fill=orange!50,angle radius=1cm,"$\gamma$"] {angle=B1--C1--A1};
\end{tikzpicture}
\end{figure}

\end{document} %%%%%

在此处输入图片描述

答案2

作为补充阿博阿马尔答案是充分利用quotes库并进行一些小的更改:

\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{angles,quotes}

\begin{document}
    \begin{figure}[ht]
    \centering
\begin{tikzpicture}[
    scale = 0.5,
     auto = right,
MA/.style = {% My Angle
            draw, fill=orange!50,
            angle radius=#1},
MA/.default = 16mm
                    ]
% coordinates
\coordinate[label=below:$A1$] (A1) at (0,0);
\coordinate[label=above:$B1$] (B1) at (0,30);
\coordinate[label=right:$C1$] (C1) at (8,20.4);
% angles' labels
\pic[MA,"$\alpha$"]     {angle=C1--A1--B1};
\pic[MA,"$\beta$"]      {angle=A1--B1--C1};
\pic[MA=8mm,"$\gamma$"] {angle=B1--C1--A1};
% triangle
\draw[line width=2pt] (C1) to ["$a_1$"] (B1)
                           to ["$c_1$"] (A1)
                           to ["$b_1$"] (C1)
                           -- cycle;
\draw[dashed]   (C1) to["$h$"] (C1 -| B1);
\end{tikzpicture}
    \end{figure}
\end{document}

相关内容