\documentclass[border=6mm]{standalone}
\usepackage {siunitx}
\usepackage {tikz}
\usetikzlibrary{angles}
\sisetup {output-decimal-marker={,}}
\begin{document}
\begin{tikzpicture}[scale=0.3,line join=round]
\def\yb{13}
\def\ac{42} % angle C
\pgfmathsetmacro\x{\yb*tan(\ac)}
\pgfmathsetmacro\h{\yb/cos(\ac)} % hypothenuse
\coordinate [label=below:$\textcolor{white}F$] (A) at (0,0);
\coordinate [label=above:$\textcolor{white}B$](B) at (0,\yb);
\coordinate [label=below:$\textcolor{white}G$](C) at (-\yb,0);
\draw[thick] (A) -- node[right] {\color{blue} $z$}
(B) -- node[sloped,above] {\color{white}hypotenuse = \num{\h}}
(C) -- node[sloped,below] {\color{white}\text{opposite} $= FG$} cycle;
\draw[thick] (B) -- node[sloped] {\color{blue}$|$}
(C) -- cycle;
\def\yt{13}
\def\ac{42} % angle C
\pgfmathsetmacro\x{\yb*tan(\ac)}
\pgfmathsetmacro\h{\yb/cos(\ac)} % hypothenuse
\coordinate [label=below:$\textcolor{white}F$] (A) at (0,0);
\coordinate [label=above:$\textcolor{white}B$](D) at (0,\yt);
\coordinate [label=below:$\textcolor{white}G$](E) at (\yt,0);
\coordinate [label=below:$\textcolor{white}G$](m) at (\yt,-2cm);
\coordinate [label=below:$\textcolor{white}G$](n) at (-\yt,-2cm);
\coordinate [label=below:$\textcolor{blue}{120}$](H) at (0,-2cm);
\draw[thick] (A) -- node[right] {\color{blue} $z$}
(D) -- node[sloped,above] {\color{white}hypotenuse = \num{\h}}
(E) -- node[sloped,below] {\color{blue}$y$} cycle;
\draw[thick] (D) -- node[sloped] {\color{blue}$|$}
(E) -- cycle;
\draw[thick](m)--(H)--(n)--cycle;
% angles, with angles library
\draw[thick] pic [draw] {angle=A--C--B} node [above,xshift=.8cm,yshift=0cm] at (C) {\ang{\ac}};
\draw[thick] pic [draw,angle radius=4mm] {right angle=B--A--C};
\end{tikzpicture}
\end{document}
如何将线放在图下方?顺便说一句,不要介意其他代码,我会在需要时使用它。
答案1
为了好玩,这很容易pstricks
:
\documentclass{article}
\usepackage{sansmath}
\usepackage[x11names]{xcolor}%
\usepackage{pst-eucl}
\begin{document}
\psset{unit=1.25cm}
\begin{pspicture}(-2,-1)(2,2) \sansmath
\psset{PointSymbol=none, PointName=none, linejoin=1, linewidth=1pt, labelsep=2pt, MarkHashLength=3mm}
\pstTriangle(0,1.8){A}(-2,0){B}(2,0){C}
\pstGeonode(0,0){O}\pcline(A)(O) \naput{$\color{DeepSkyBlue3}z$}\uput[d](1,0){$\color{DeepSkyBlue3}y$}
{\psset{linecolor=Coral2, SegmentSymbol=MarkHash, MarkAngle=90}
\pstRightAngle{A}{O}{B}
\pstMarkAngle[linestyle=none]{C}{B}{A}{$\color{DeepSkyBlue3}42^{\circ}$}
\pstSegmentMark{A}{B}\pstSegmentMark{A}{C}}
\pstTriangle(0,1.8){A}(-2,0){B}(2,0){O}
\pcline[offset=-15pt, linecolor=DeepSkyBlue3]{|-|}(B)(C)
\ncput*[nrot=:U]{$\color{DeepSkyBlue3}120$}
\end{pspicture}
\end{document}
答案2
这只是另一种非常接近此类绘图的方法,以便让您知道如何在非水平的情况下绘制这些测量线(并且无需使用任何可以自动执行此操作的花哨库):
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,arrows.meta,quotes,angles}
\tikzset{
measure/.style = {thin,
{Bar[width=2.2mm]Latex[]}-%
{Latex[]Bar[width=2.2mm]},
}
}
\begin{document}
\begin{tikzpicture}[thick,font=\sffamily]
\def\angleI{10} % tilt angle
\def\angleB{42} % B angle
\def\a{6}
\pgfmathsetmacro\b{0.5*\a/cos(\angleB)}
\path (0,0) coordinate (B)
(\angleI:\a) coordinate (C)
($(B)+(\angleI+\angleB:\b)$) coordinate (A)
($(B)!0.5!(C)$) coordinate (H);
\draw (A) node[above]{A} -- (B) node[midway,sloped,red]{\large $|$} node[left]{B} -- (C) node[near end,above,cyan]{y} node[right]{C} -- (A) node[midway,sloped,red]{\large $|$} -- cycle
(A) -- (H) node[midway,right,cyan]{z} ;
\draw[red] pic [draw,angle radius=3mm] {right angle=A--H--B};
\draw[purple] pic [draw] {angle=C--B--A} node [xshift=8mm,yshift=4mm] at (B) {\angleB$^\circ$};
\draw[measure,cyan] ($(B)!5mm!-90:(C)$) -- ($(C)!5mm! 90:(B)$) node[midway,sloped,fill=white]{120};
\end{tikzpicture}
\end{document}
答案3
我不知道我是否理解正确了这个问题。但是你想要图形下方的黑线?例如,你可以使用\newcommand{\decoRule}{\rule{\textwidth}{0.6pt}}
\documentclass[border=6mm]{article}
\usepackage {siunitx}
\usepackage {tikz}
\usetikzlibrary{angles}
\sisetup {output-decimal-marker={,}}
\newcommand{\decoRule}{\rule{\textwidth}{0.6pt}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.3,line join=round]
\def\yb{13}
\def\ac{42} % angle C
\pgfmathsetmacro\x{\yb*tan(\ac)}
\pgfmathsetmacro\h{\yb/cos(\ac)} % hypothenuse
\coordinate [label=below:$\textcolor{white}F$] (A) at (0,0);
\coordinate [label=above:$\textcolor{white}B$](B) at (0,\yb);
\coordinate [label=below:$\textcolor{white}G$](C) at (-\yb,0);
\draw[thick] (A) -- node[right] {\color{blue} $z$}
(B) -- node[sloped,above] {\color{white}hypotenuse = \num{\h}}
(C) -- node[sloped,below] {\color{white}\text{opposite} $= FG$} cycle;
\draw[thick] (B) -- node[sloped] {\color{blue}$|$}
(C) -- cycle;
\def\yt{13}
\def\ac{42} % angle C
\pgfmathsetmacro\x{\yb*tan(\ac)}
\pgfmathsetmacro\h{\yb/cos(\ac)} % hypothenuse
\coordinate [label=below:$\textcolor{white}F$] (A) at (0,0);
\coordinate [label=above:$\textcolor{white}B$](D) at (0,\yt);
\coordinate [label=below:$\textcolor{white}G$](E) at (\yt,0);
\coordinate [label=below:$\textcolor{white}G$](m) at (\yt,-2cm);
\coordinate [label=below:$\textcolor{white}G$](n) at (-\yt,-2cm);
\coordinate [label=below:$\textcolor{blue}{120}$](H) at (0,-2cm);
\draw[thick] (A) -- node[right] {\color{blue} $z$}
(D) -- node[sloped,above] {\color{white}hypotenuse = \num{\h}}
(E) -- node[sloped,below] {\color{blue}$y$} cycle;
\draw[thick] (D) -- node[sloped] {\color{blue}$|$}
(E) -- cycle;
\draw[thick](m)--(H)--(n)--cycle;
% angles, with angles library
\draw[thick] pic [draw] {angle=A--C--B} node [above,xshift=.8cm,yshift=0cm] at (C) {\ang{\ac}};
\draw[thick] pic [draw,angle radius=4mm] {right angle=B--A--C};
\end{tikzpicture}
\decoRule
\caption[a triangle]{A description comes here}\label{triangle}
\end{figure}
\end{document}