即使文本插入在“pspicture”部分上方,文本也会出现在其后面。如何保持顺序?

即使文本插入在“pspicture”部分上方,文本也会出现在其后面。如何保持顺序?

我希望标题“不规则三角形”出现在图表上方。但即使将文本插入到该部分上方,情况也不会如此。

代码:

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}

\usepackage{FiraMono}
\usepackage[T1]{fontenc}


\begin{document}
    \section{Triangles}
    \subsection{Scalene Triangle}
    \newline
    \begin{pspicture}(0,0)
        \pspolygon(1,1)(3,4)(9,1)   %triangle
        \psline[linestyle=dashed](3,4)(3,1) %height
        \pspolygon(3,1)(3,1.2)(3.2,1.2)(3.2,1)  %right angle
        \uput{0.1}[180](1,1){A}
        \uput{0.1}[90](3,4){B}
        \uput{0.1}[0](9,1){C}
        \uput{0.2}[0](6,2.5){a}
        \uput{0.2}[270](5,1){b}
        \uput{0.2}[180](2,2.5){c}
        \uput{0.2}[0](3,2.5){h}
    \end{pspicture} 
    $$area = \sqrt{s(s-a)(s-b)(s-c)},\quad s = \frac{(a+b+c)}{2}$$
    \subsection{Right Angled Triangle}
\end{document}

输出:

在此处输入图片描述

请忽略旧代码

我的代码:

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}

\usepackage{FiraMono}
\usepackage[T1]{fontenc}


\begin{document}
    SCALENE TRIANGLE
\begin{pspicture}(0,0)
    \pspolygon(1,1)(3,4)(9,1)   %triangle
    \psline[linestyle=dashed](3,4)(3,1) %height
    \pspolygon(3,1)(3,1.2)(3.2,1.2)(3.2,1)  %right angle
    \uput{0.1}[180](1,1){A}
    \uput{0.1}[90](3,4){B}
    \uput{0.1}[0](9,1){C}
    \uput{0.2}[0](6,2.5){a}
    \uput{0.2}[270](5,1){b}
    \uput{0.2}[180](2,2.5){c}
    \uput{0.2}[0](3,2.5){h}
\end{pspicture}
    $$area = \sqrt{s(s-a)(s-b)(s-c)},\quad s = \frac{(a+b+c)}{2}$$
\end{document}

输出:

输出

答案1

我建议使用更短的代码pst-eucl,专用于平面几何。无需坐标计算 - 仅使用 A、B、C 的坐标:

\documentclass[svgnames]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pst-node, pst-eucl}
\usepackage{amsmath}
\usepackage{FiraMono}

\begin{document}

\section{Triangles}
\subsection{Scalene Triangle}
\begin{center}
    \begin{pspicture*}(0.5,0.5)(9.5,4.5)
        \psset{PointSymbol = none, RightAngleSize = 0.2, linecolor = NavyBlue}
        \pstTriangle[PosAngle = {180,90,0}](1,1){A}(3,4){B}(9,1){C} %triangle
        \pstProjection[CodeFig, linewidth = 0.4pt, CodeFigColor = Tomato]{A}{C}{B}[H]\naput{$ h $}
        \psset{linestyle = none, labelsep = 2pt}
        \ncline{B}{C}\naput{$a$}
        \ncline{C}{A}\naput{$b$}
        \ncline{A}{B}\naput{$c$}
    \end{pspicture*}
\end{center}
\[ \text{area} = √{s(s-a)(s-b)(s-c)},\quad s = \frac{a+b+c}{2} \]

\end{document} 

在此处输入图片描述

答案2

使用可选参数[showgrid]。然后您将看到为图像保留了哪个矩形。如果一切正常,请设置showgrid=false

\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{FiraMono}
\usepackage[T1]{fontenc}

\begin{document}
    \section{Triangles}
    \subsection{Scalene Triangle}

    \begin{pspicture}[showgrid](10,5)
    \pspolygon(1,1)(3,4)(9,1)   %triangle
    \psline[linestyle=dashed](3,4)(3,1) %height
    \pspolygon(3,1)(3,1.2)(3.2,1.2)(3.2,1)  %right angle
    \uput{0.1}[180](1,1){A}
    \uput{0.1}[90](3,4){B}
    \uput{0.1}[0](9,1){C}
    \uput{0.2}[0](6,2.5){a}
    \uput{0.2}[270](5,1){b}
    \uput{0.2}[180](2,2.5){c}
    \uput{0.2}[0](3,2.5){h}
    \end{pspicture} 

    \[\textrm{area} = \sqrt{s(s-a)(s-b)(s-c)},\quad s = \frac{(a+b+c)}{2}\]

    \subsection{Right Angled Triangle}
\end{document}

相关内容