将标签设置为更接近它们所代表的坐标

将标签设置为更接近它们所代表的坐标

五边形是根据以下代码绘制的。我将顶点标记为ABCDP。这些标签距离它们所代表的点太远。我使用了label命令的选项coordinate将标签放置在它们的点附近。因此,我认为标签将直接放置在坐标上,这并不合适。(我被告知指定一个角度,例如180,会在点附近提供一些“填充”。)我仍然需要一个命令来移动标签。我现在知道移动点附近标签的语法是

[label distance=<distance>]<angle>:<name for the label>

点与其标签之间的默认距离是多少?指定角度时会添加多少填充。我想抑制此填充或使用它label distance=<distance>来补偿它。

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


\begin{document}


\begin{tikzpicture}

\coordinate[label={225:$A$}] (A) at (-0.5,-0.75);
\coordinate[label={135:$B$}] (B) at (-0.5,0.5);
\coordinate[label={45:$C$}] (C) at (1,0.5);
\coordinate[label={-45:$D$}] (D) at (1,-0.75);

\draw (A) -- (B) -- (C) -- (D) -- (A) -- cycle;

\path (A) -- (C);
\path (B) -- (D);

\path[name path=ray1] (C) -- ($(C)!1.5cm!90:(A)$);
\path[name path=ray2] (D) -- ($(D)!1.5cm!-90:(B)$);


\coordinate[name intersections={of=ray1 and ray2,by={P}}];
\node[label={right:$P$}] at (P) {};


\draw (C) -- (P) -- (D);

%\draw[line width=0.1pt, draw=gray!25] (current bounding box.south west) grid (current bounding box.north east);
\end{tikzpicture}

\end{document}

答案1

您可以应用该label distance=<distance>样式。下面我将这种样式应用于ADP,但是不是 B这样C就可以看到效果了:

在此处输入图片描述

代码:

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


\begin{document}


\begin{tikzpicture}

\coordinate[label={[label distance=-3pt]225:$A$}] (A) at (-0.5,-0.75);
\coordinate[label={135:$B$}] (B) at (-0.5,0.5);
\coordinate[label={45:$C$}] (C) at (1,0.5);
\coordinate[label={[label distance=-3pt]-45:$D$}] (D) at (1,-0.75);

\draw (A) -- (B) -- (C) -- (D) -- (A) -- cycle;

\path (A) -- (C);
\path (B) -- (D);

\path[name path=ray1] (C) -- ($(C)!1.5cm!90:(A)$);
\path[name path=ray2] (D) -- ($(D)!1.5cm!-90:(B)$);


\coordinate[name intersections={of=ray1 and ray2,by={P}}];
\node[label={[label distance=-5pt]right:$P$}] at (P) {};


\draw (C) -- (P) -- (D);

%\draw[line width=0.1pt, draw=gray!25] (current bounding box.south west) grid (current bounding box.north east);
\end{tikzpicture}

\end{document}

相关内容