# Setting labels closer to the coordinates that they represent [duplicate]

A pentagon is drawn from the following code. I label the vertices A, B, C, D, and P. The labels are too far from the points that they represent. I used the label option for the coordinate command to place the labels about their points. So, I thought that the labels would be placed directly over the coordinates, which wouldn't have been appropriate. (I was told that having an angle specified, such as 180, provides some "padding" about the point.) I would still have needed a command to move the label. I now know they syntax for moving the label about the point is

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

What is the default distance between a point and its label? How much padding is added when an angle is specified. I would like to either suppress this padding or use label distance=<distance> to compensate for it.

\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}

• Is this a duplicate? – Alenanno May 16 '15 at 17:34
• @Alenanno I may have used the code in a previous post. I just put the labels on the pentagon. So, I know that if I had the code in a previous post, it wasn't about the placement of labels. – user74973 May 16 '15 at 19:02
• That comment was a link to another question. The answer to that question will help you solve this one. That's what "duplicate" means. :) – Alenanno May 16 '15 at 19:29
• @Alenanno I did not see that it was typeset in blue. Yes, my post is a duplicate. I had not seen the label distance= option. The syntax for label as an option for coordinate is odd. You have to put label distance=<distance> within braces. There is no comma separating it from the angle at which you want to place the label about the point. After both of these, a colon and the label are given. – user74973 May 16 '15 at 19:49

## 1 Answer

You can apply the label distance=<distance> style. In the following I applied this style to A, D and P, but not B and C so that the effect can be seen:

## Code:

\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}

• The suggestion [label distance=-3pt] that you give looks quite nice. – user74973 May 16 '15 at 19:43
• What is the default separation between a label and coordinates when using coordinate? – user74973 May 16 '15 at 19:43
• @user74973: The default is 0pt, but since you specified an angle that itself has some padding built is (not sure what it is), but you could experiment to see what adjustment you need to get the label back onto the center of the coordinate. – Peter Grill May 16 '15 at 19:47
• Would the commands \draw [help lines] (-2,-2) grid (2,2);, path [fill=blue] (0,0) circle (1pt);, and \coordinate[label={[label distance=-4pt]0:$.$}] (A) at (0,0); help me find the default distance when I have an angle of 0 degrees? (I place a blue dot at the origin with a path command and a . near the origin with a coordinate command.) I just change -4pt until the . is at the origin. Is that what you were suggesting? – user74973 May 16 '15 at 19:59
• @user74973: Yep, that is what I was suggesting. – Peter Grill May 16 '15 at 20:41