我想画出上面的三角形,但我只能画出下面的三角形 -
我该如何绘制并重新创建顶部的形状?我无法正确放置 x、y 并生成角度 alpha 和直角符号。
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (7,0);
\coordinate (c) at (5,3);
\draw (a) -- (b)node[midway, below]{$x$} -- (c)node[midway,right]{$z$} -- (a)node[midway,left, above]{c}; % Triangle.
\draw (a) node[anchor=east,align=center] {A};
\draw (b) node[anchor=west,align=center] {B};
\draw (c) node[anchor=south]{C};
%line
\draw (2.366,2.451) -- (4.526,-0.789)
\end{tikzpicture}
\end{document}
此外,我可以在哪里学习 LaTeX 的内在知识并绘制像上面这样的复杂形状?
答案1
您可以借助库来放置定义与 BC 平行的线的点calc
。例如,
\coordinate (ab) at ($(a)!0.6!(b)$);
(ab)
在(a)
和之间创建一个点(b)
,距离 分别为 60%(a)
和 40% (b)
。
angles
这两个角度都可以用和quotes
(最后一个用于标签)库来绘制。这
\draw[red] pic ["$\alpha$",draw] {angle=ac--ab--a};
绘制一个顶点的角度(ab)
并将其标记为 alpha。
完整的代码可能是:
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{tikzpicture}
% coordinates
\coordinate (a) at (0,0);
\coordinate (b) at (7,0);
\coordinate (c) at ($(a)!0.5!(b)+(60:3.5)$);
\coordinate (ab) at ($(a)!0.6!(b)$); % point for the line parallel to BC (calc library)
\coordinate (ac) at ($(a)!0.6!(c)$); % point for the line parallel to BC (calc library)
% triangle
\draw (a) node [left] {$A$} -- (b) node [right] {$B$} -- (c) node [above] {$C$} -- cycle;
% labels
\node at ($(a)!0.5!(ab)$) [below] {$x$};
\node at ($(ac)!0.5!(c)$) [above] {$y$};
\node at ($(b)!0.5!(c)$) [right] {$z$};
% line
\draw[shorten <= -1 cm, shorten >= -1cm] (ab) -- (ac);
% angles (angles and quotes libraries)
\draw[red] pic ["$\alpha$",draw] {angle=ac--ab--a};
\draw[red] pic [draw,angle radius=3mm] {right angle=a--c--b};
\end{tikzpicture}
\end{document}
编辑:我改变了 C 坐标。现在它有一个正确的角度。
答案2
可以使用pstricks
,更准确地说是pst-eucl
,它定义了模拟用尺子和圆规构造的工具。具体来说,我在这里使用命令\pstHomO
,它只需一步即可构建点族的同源性:
\documentclass[border=6pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(-2,-0.5)(2,2)
\psset{PointSymbol=none, PointName=none, linejoin=1, linewidth=0.5pt}
\SpecialCoor
\pstTriangle[PosAngle={120,-130,-30}](2; 60){A}(-2,0){B}(2,0){C}
\pstRightAngle[RightAngleSize=0.2]{B}{A}{C}
\pstHomO[HomCoef=0.6]{B}{A,C}[H,I]
\pstLineAB[nodesep=-0.5]{H}{I}
\pstMarkAngle[LabelSep=0.3, MarkAngleRadius=0.45]{H}{I}{B}{$\alpha$}
\foreach \s/\t/\lbl in {I/B/x, H/A/y, A/C/z} {\pstLabelAB[linestyle=none, offset=1ex]{\s}{\t}{$\lbl$}}
\end{pspicture}
\end{document}