Is there an equivalent to \uput in TikZ?
You might find the quotes
library convenient.
Here's one way of adding the label without using the quotes syntax. I wouldn't actually bother with intersections
here but would just use the midpoint of the short diagonal.
\begin{tikzpicture}[x=0.06\linewidth, y=0.06\linewidth, line width=.8pt]
\coordinate [label=45:$A$] (A) at (6,6);
\coordinate [label=135:$B$] (B) at (1,4);
\coordinate [label=-45:$D$] (D) at (4,1);
\coordinate [label=-120:$C$] (C) at (0,0);
\draw (A) -- (B) -- (C) -- (D) -- cycle (A) -- (C) (B) -- (D) node [midway, above] {$P$};
\end{tikzpicture}
Using the quotes
library enables us to use a more concise syntax. Combined with the edge
operation, we can then construct a similar diagram using the following line of code.
\draw (0,0) coordinate ["-120:$C'$"] (C') -- +(4,1) coordinate ["-45:$D'$"] (D') -- +(6,6) coordinate ["45:$A'$"] (A') edge (C') -- +(1,4) coordinate ["135:$B'$"] (B') edge ["$P'$" right, pos=.35] (D') -- cycle;
"<specification>"
adds a label (in the case of a coordinate or node) or a node (in the case of an edge). "<specification>"'
'swaps' the location of the label or node if auto
placement is being used. In the case of a label, "<angle>:<text>"
can be used to place the label node at a precise angle. right
, above
etc. are redefined within the specification to refer to the various 'standard' angles you might choose. Standard styles are available to set up custom defaults for format and placement.
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}[x=0.06\linewidth, y=0.06\linewidth, line width=.8pt]
\coordinate [label=45:$A$] (A) at (6,6);
\coordinate [label=135:$B$] (B) at (1,4);
\coordinate [label=-45:$D$] (D) at (4,1);
\coordinate [label=-120:$C$] (C) at (0,0);
\draw (A) -- (B) -- (C) -- (D) -- cycle (A) -- (C) (B) -- (D) node [midway, above] {$P$};
\begin{scope}[xshift=50mm]
\draw (0,0) coordinate ["-120:$C'$"] (C') -- +(4,1) coordinate ["-45:$D'$"] (D') -- +(6,6) coordinate ["45:$A'$"] (A') edge (C') -- +(1,4) coordinate ["135:$B'$"] (B') edge ["$P'$" right, pos=.35] (D') -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}
EDIT
As I understand it, when placing a label or pin etc., TikZ tries to be rather more clever than you may wish. If you request a non-standard angle, it 'snaps' the anchor
of the node to the nearest compass point e.g. 30
, 90
, 110
etc. So, to enforce the angle, you need to enforce the anchor
.
For example,
... coordinate [label={[anchor=-5]-185:$C$}, label={[anchor=15]-165:$C$}, label={-135:$C$}, label={[anchor=60]-120:$C$}] (C) ...
produces
To place the P
label, I would just create a shifted edge node
. For example,
... edge node [midway, shift=(80:12pt)] {$P$} ...
produces
Complete code:
\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=0.06\linewidth, y=0.06\linewidth, line width=.8pt]
\draw (0,0) coordinate [label={[anchor=-5]-185:$C$}, label={[anchor=15]-165:$C$}, label={-135:$C$}, label={[anchor=60]-120:$C$}] (C) -- +(4,1) coordinate [label=-45:$D$] (D) -- +(6,6) coordinate [label=45:$A$] (A) edge (C) -- +(1,4) coordinate [label=135:$B$] (B) edge node [midway, shift=(80:12pt)] {$P$} (D) -- cycle;
\end{tikzpicture}
\end{document}
See, if the following MWE can help you:
\documentclass[ tikz,
border=3mm,
12pt]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[x=0.06\linewidth, y=0.06\linewidth,
every label/.style = {label distance=3pt, inner sep=1pt},
every path/.style = {draw, line width=0.8pt}
]
\coordinate [label=45:$A$] (A) at (6,6);
\coordinate [label=135:$B$] (B) at (1,4);
\coordinate [label=-45:$D$] (D) at (4,1);
\coordinate [label=-120:$C$] (C) at (0,0);
\path (A) -- (B) -- (C) -- (D) -- cycle;
\path [name path=A--C] (A) -- (C);
\path [name path=B--D] (B) -- (D);
\path [name intersections={of=A--C and B--D,by={[label=above:$P$]P}}];
\end{tikzpicture}
\end{document}