绘制线条厚度为默认厚度的一半

绘制线条厚度为默认厚度的一半

在下面的代码中,绘制了两个三角形 - 一个是另一个沿直线 y=x 的反射。我想用命令 绘制一条线,该线的\draw[loosely dash dot]粗细是三角形 AB'C' 中虚线的一半或三分之一。我希望这条线包含 B' 和 C' 之间的线段。为此,我需要将节点 B' 和 C' 向右移动,或者我需要将 B' 和 C' 排版到线上,并在它们周围留出一些空间。

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{mathtools,systeme,array}

\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}


\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,clip=false,
axis lines=middle,
xmin=-7,xmax=17,
xlabel=$x$,ylabel=$y$,
ymin=-7,ymax=17,
restrict y to domain=-7:17,
enlargelimits={abs=0.25cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={\empty},ytick={\empty},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[dashed,latex-latex,samples=2,domain=-6:16]{x};


\draw (axis cs:-3,-3) coordinate(A) node[above left]{$A$};
\draw (axis cs:0,10.5) coordinate(B) node[above left]{$B$};
\draw (axis cs:5,13) coordinate(C) node[above right]{$C$};
\draw (axis cs:3,9) coordinate(P);

\draw (axis cs:10.5,0) coordinate(b) node[below]{$B^{\prime}$};
\draw (axis cs:13,5) coordinate(c) node[above right]{$C^{\prime}$};
\draw (axis cs:9,3) coordinate(p);
\end{axis}

\draw (A) -- (B) -- (C) -- cycle;
\draw[dashed] (B) -- (P);
\tkzMarkRightAngle(A,P,B);

\draw[dashed] (A) -- (b) -- (c) -- cycle;
\draw[dotted] (b) -- (p);
\tkzMarkRightAngle[densely dotted](A,p,b);

\end{tikzpicture}



\end{document}

答案1

您可以按照 Sigur 的评论进行设置line width,并且可以通过以下方式访问默认线宽\pgflinewidth

line width=0.5\pgflinewidth

对于线名称loosely dash dot节点bpcp

\draw (axis cs:10.5,0) coordinate(b) node[below](bp){$B^{\prime}$};
\draw (axis cs:13,5) coordinate(c) node[above right](cp){$C^{\prime}$};

进而

\draw[line width=0.5\pgflinewidth,loosely dash dot] (bp.center) -- (cp.center);

完整代码如下:

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{mathtools,systeme,array}

\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}


\begin{document}


\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,clip=false,
axis lines=middle,
xmin=-7,xmax=17,
xlabel=$x$,ylabel=$y$,
ymin=-7,ymax=17,
restrict y to domain=-7:17,
enlargelimits={abs=0.25cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={\empty},ytick={\empty},
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]
\addplot[dashed,latex-latex,samples=2,domain=-6:16]{x};


\draw (axis cs:-3,-3) coordinate(A) node[above left]{$A$};
\draw (axis cs:0,10.5) coordinate(B) node[above left]{$B$};
\draw (axis cs:5,13) coordinate(C) node[above right]{$C$};
\draw (axis cs:3,9) coordinate(P);

\draw (axis cs:10.5,0) coordinate(b) node[below](bp){$B^{\prime}$};
\draw (axis cs:13,5) coordinate(c) node[above right](cp){$C^{\prime}$};
\draw (axis cs:9,3) coordinate(p);
\end{axis}

\draw (A) -- (B) -- (C) -- cycle;
\draw[dashed] (B) -- (P);
\tkzMarkRightAngle(A,P,B);

\draw[dashed] (A) -- (b) -- (c) -- cycle;
\draw[dotted] (b) -- (p);
\tkzMarkRightAngle[densely dotted](A,p,b);

\draw[line width=0.5\pgflinewidth,loosely dash dot] (bp.center) -- (cp.center);

\end{tikzpicture}



\end{document}

相关内容