毕达哥拉斯定理论证图

毕达哥拉斯定理论证图

以下代码给出了我想要的显示。但是我必须发出额外的命令,因为以下节点命令的语法有错误。

\draw (A) -- node[midway, below left]{b} -- (C); -- node[midway, above right]{a} -- (P) node[midway, above]{y} -- (A) node[midway, above]{x};

(三角形的顶点为AB和 ;从到 线段的C高的脚为。)为什么无法编译该命令?CABPTikZ

\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections}



\begin{document}


\begin{tikzpicture}

\coordinate (C) at (0,0);
\node (vertex_C) at ($(C) + (-90:7.5pt)$){$C$};
\coordinate (A) at (135:4);
\node (vertex_A) at ($(A) + (150:7.5pt)$){$A$};
\coordinate (B) at (45:5);
\node (vertex_B) at ($(B) + (30:7.5pt)$){$B$};
\draw (C) -- (A) -- (B) -- (C);

%Draw the height of the triangle from C to line segment $AB$.
%Label the height $h$.
\coordinate (P) at ($(A)!(C)!(B)$);
\draw [dashed] (C) -- (P) node [midway, right]{$h$};

%Label sides of triangle.
\coordinate (AC_midpoint) at ($(A)!0.5!(C)$);
\node (AC_midpoint_label) at ($(AC_midpoint) + (225:7.5pt)$) {$b$};
\coordinate (BC_midpoint) at ($(B)!0.5!(C)$);
\node (BC_midpoint_label) at ($(BC_midpoint) + (-45:7.5pt)$) {$a$};
\coordinate (PA_midpoint) at ($(P)!0.5!(A)$);
\node (PA_midpoint_label) at ($(PA_midpoint) + (90:5pt)$) {$x$};
\coordinate (PB_midpoint) at ($(P)!0.5!(B)$);
\node (PB_midpoint_label) at ($(PB_midpoint) + (90:5pt)$) {$y$};
\draw[decorate,decoration={brace,raise=12pt,amplitude=5pt}] (A) -- node[above left=7mm and 0.125mm, fill=white, inner sep=1pt]{$c$} (B);


%Right-angle mark at vertex C.
\coordinate (U) at ($(C)!4mm!-45:(A)$);
\draw (U) -- ($(C)!(U)!(A)$);
\draw (U) -- ($(C)!(U)!(B)$);

\filldraw[fill=white] (C) -- ($(C)!(U)!(A)$) -- (U) -- ($(C)!(U)!(B)$) -- cycle;


%Right-angle mark at foot of the altitude.
\coordinate (V) at ($(P)!4mm!45:(C)$);
\draw (V) -- ($(P)!(V)!(C)$);
\draw (V) -- ($(P)!(V)!(B)$);

\end{tikzpicture}

\end{document}

答案1

John Kormylo 用你的语法概括了问题的要点,我认为从你的非工作命令来看,你的代码可以简化。

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}

\coordinate[label={270:$C$}] (C) at (0,0);
\coordinate[label={150:$A$}] (A) at (135:4);
\coordinate[label={30:$B$}] (B) at (45:5);

\draw (C) -- (A)node[midway,below left]{$b$} -- (B)  -- cycle
       node[midway,below right]{$a$};
\draw [dashed] (C) -- ($(A)!(C)!(B)$) coordinate (P) node [midway, right]{$h$};

\draw[decorate,decoration={brace,raise=12pt,amplitude=5pt}] (A) -- (B);
\path (B) -- (P) node[midway,above]{$x$}-- (A) node[midway,above]{$y$} 
($($(A)!0.5!(B)$)!0.8cm!90:(B)$) node {$c$}; % You can nest calc syntax!

\filldraw[fill=white] (C) -- ($(C)!2mm!(A)$) coordinate (U) -- ($(U)!2mm!90:(C)$) 
      --($(C)!2mm!(B)$) --cycle;
\draw ($(P)!2mm!(C)$) coordinate (V) -- ($(V)!2mm!90:(C)$) --($(P)!2mm!(B)$);
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容