与三角形边平行的标签

与三角形边平行的标签

以下代码经过编译后可生成一个直角三角形。直角边和斜边的长度标签均存在且为“倾斜”。我希望它们位于三角形之外。

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}


\begin{document}

\begin{tikzpicture}
\path (135:3) coordinate (A) (45:4) coordinate (B) (0:0) coordinate (C);
\draw (A)
-- (B) node [at start, above left]{$A$} node [midway, sloped]{$m + n$}
-- (C) node [at start, above left]{$B$} node [midway, sloped] {$2\sqrt{mn}$}
-- (A) node [at start, below]{$C$} node [midway, sloped]  {$m - n$} -- cycle;
\draw pic[draw, angle radius=7.5mm,"$\theta$",angle eccentricity=1.5] {angle = C--A--B};
\tkzMarkRightAngle(A,C,B);
\end{tikzpicture}

\end{document}

答案1

只需根据需要添加abovebelow即可。参见:

在此处输入图片描述

修改后的代码:

\documentclass[10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}


\begin{document}

\begin{tikzpicture}
\path (135:3) coordinate (A) (45:4) coordinate (B) (0:0) coordinate (C);
\draw (A)
-- (B) node [at start, left]{$A$} node [midway,above, sloped]{$m+n$}
-- (C) node [at start, right]{$B$} node [midway,below, sloped] {$2\sqrt{m n}$}
-- (A) node [at start, below]{$C$} node [midway, below, sloped] {$m-n$} -- cycle;
\draw pic[draw, angle radius=7.5mm,"$\theta$",angle eccentricity=1.3] {angle = C--A--B};
\tkzMarkRightAngle(A,C,B);
\end{tikzpicture}

\end{document}

答案2

只是为了用 PSTricks 来找点乐子的解决方案。

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(10,7)
    \pstGeonode[CurveType=polygon,PosAngle={180,-90,0}](1,4){A}(5,1){C}([offset=-7]{A}C){B}
    \pstRightAngle{A}{C}{B}
    \pstMarkAngle[MarkAngleRadius=1,LabelSep=1.5]{C}{A}{B}{$\theta$}
    \psset{shortput=nab,linestyle=none,nrot=:U}
    \pcline(A)(B)^{$m+n$}
    \pcline(A)(C)_{$m-n$}
    \pcline(C)(B)_{$2\sqrt{mn}$}
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容