Debian Codegraph @

texmf-dist/doc/latex/tkz-euclide/TKZdoc-euclide-labelling.tex

raw
1 \section{Labelling}
2 \subsection{Label for a point}
3 \hypertarget{tlp}{}
4 It is possible to add several labels at the same point by using this macro several times.
5
6 \begin{NewMacroBox}{tkzLabelPoint}{\oarg{local options}\parg{point}\var{label}}%
7 \begin{tabular}{lll}%
8 arguments & example & \\
9 \midrule
10 \TAline{point}{\tkzcname{tkzLabelPoint(A)\{\$A\_1\$\}}}{}
11 options & default & definition\\
12 \midrule
13 \TOline{TikZ options}{}{colour, position etc.}
14 \bottomrule
15 \end{tabular}
16
17 \medskip
18 Optionally, we can use any style of \TIKZ, especially placement with above, right, dots...
19 \end{NewMacroBox}
20
21 \subsubsection{Example with \tkzcname{tkzLabelPoint}}
22 \begin{tkzexample}[latex=7cm,small]
23 \begin{tikzpicture}
24 \tkzDefPoint(0,0){A}
25 \tkzDefPoint(4,0){B}
26 \tkzDefPoint(0,3){C}
27 \tkzDrawSegments(A,B B,C C,A)
28 \tkzDrawPoints(A,B,C)
29 \tkzLabelPoint[left,red](A){$A$}
30 \tkzLabelPoint[right,blue](B){$B$}
31 \tkzLabelPoint[above,purple](C){$C$}
32 \end{tikzpicture}
33 \end{tkzexample}
34
35 \subsubsection{Label and reference}
36 The reference of a point is the object that allows to use the point, the label is the name of the point that will be displayed.
37
38 \begin{tkzexample}[latex=6cm,small]
39 \begin{tikzpicture}
40 \tkzDefPoint(2,0){A}
41 \tkzDrawPoint(A)
42 \tkzLabelPoint[above](A){$A_1$}
43 \end{tikzpicture}
44 \end{tkzexample}
45
46 \subsection{Add labels to points \tkzcname{tkzLabelPoints}}
47 It is possible to place several labels quickly when the point references are identical to the labels and when the labels are placed in the same way in relation to the points. By default, \tkzname{below right} is chosen.
48 \hypertarget{tlps}{}
49
50 \begin{NewMacroBox}{tkzLabelPoints}{\oarg{local options}\parg{$A_1,A_2,...$}}%
51 \begin{tabular}{lll}
52 arguments & example & result \\
53 \midrule
54 \TAline{list of points}{\tkzcname{tkzLabelPoints(A,B,C)}}{Display of $A$, $B$ and $C$}
55 \bottomrule
56 \end{tabular}
57
58 \medskip
59 This macro reduces the number of lines of code, but it is not obvious that all points need the same label positioning.
60 \end{NewMacroBox}
61
62 \subsubsection{Example with \tkzcname{tkzLabelPoints}}
63 \begin{tkzexample}[latex = 6cm,small]
64 \begin{tikzpicture}
65 \tkzDefPoint(2,3){A}
66 \tkzDefShiftPoint[A](30:2){B}
67 \tkzDefShiftPoint[A](30:5){C}
68 \tkzDrawPoints(A,B,C)
69 \tkzLabelPoints(A,B,C)
70 \end{tikzpicture}
71 \end{tkzexample}
72 %<--------------------------------------------------------------------------->
73 % tkzAutoLabelPoints
74 %<--------------------------------------------------------------------------->
75 \subsection{Automatic position of labels \tkzcname{tkzAutoLabelPoints}}
76 The label of a point is placed in a direction defined by a center and a point \tkzname{center}. The distance to the point is determined by a percentage of the distance between the center and the point. This percentage is given by \tkzname{dist}.
77 \begin{NewMacroBox}{tkzAutoLabelPoints}{\oarg{local options}\parg{$A_1,A_2,...$}}%
78 \begin{tabular}{lll}
79 arguments & example & result \\
80 \midrule
81 \TAline{list of points}{\tkzcname{tkzAutoLabelPoint(A,B,C)}}{Display of $A$, $B$ and $C$}
82 \end{tabular}
83 \end{NewMacroBox}
84
85 \subsubsection{Label for points with \tkzcname{tkzAutoLabelPoints}}
86 Here the points are positioned relative to the center of gravity of $A,B,C \text{ and } O$.
87 \begin{tkzexample}[latex=4cm,small]
88 \begin{tikzpicture}[scale=1]
89 \tkzDefPoint(2,1){O}
90 \tkzDefRandPointOn[circle=center O radius 1.5]\tkzGetPoint{A}
91 \tkzDefPointBy[rotation=center O angle 100](A)\tkzGetPoint{C}
92 \tkzDefPointBy[rotation=center O angle 78](A)\tkzGetPoint{B}
93 \tkzDrawCircle(O,A)
94 \tkzDrawPoints(O,A,B,C)
95 \tkzDrawSegments(C,B B,A A,O O,C)
96 \tkzDefTriangleCenter[centroid](A,B,C) \tkzGetPoint{G}
97 \tkzDrawPoint(tkzPointResult)
98 \tkzAutoLabelPoints[center=G,dist=.5](O,A,B,C)
99 \end{tikzpicture}
100 \end{tkzexample}
101
102
103
104
105 \section{Label for a segment}
106 \hypertarget{tls}{}
107 \begin{NewMacroBox}{tkzLabelSegment}{\oarg{local options}\parg{pt1,pt2}\marg{label}}
108 This macro allows you to place a label along a segment or a line. The options are those of \TIKZ\ for example \tkzname{pos}.
109
110 \medskip
111 \begin{tabular}{lll}%%
112 argument & example & definition \\
113 \midrule
114 \TAline{label}{\tkzcname{tkzLabelSegment(A,B)\{$5$\}}}{label text}
115 \TAline{(pt1,pt2)}{(A,B)}{label along $[AB]$}
116 \bottomrule
117 \end{tabular}
118
119 \medskip
120 \begin{tabular}{lll}%
121 options & default & definition \\
122 \midrule
123 \TOline{pos}{.5}{label's position}
124 \end{tabular}
125 \end{NewMacroBox}
126
127 \subsubsection{First example}
128 \begin{tkzexample}[latex=7 cm,small]
129 \begin{tikzpicture}
130 \tkzDefPoint(0,0){A}
131 \tkzDefPoint(6,0){B}
132 \tkzDrawSegment(A,B)
133 \tkzLabelSegment[above,pos=.8](A,B){$a$}
134 \tkzLabelSegment[below,pos=.2](A,B){$4$}
135 \end{tikzpicture}
136 \end{tkzexample}
137
138 \subsubsection{Example : blackboard}
139 \begin{tkzexample}[latex=6cm,small]
140 \tikzstyle{background rectangle}=[fill=black]
141 \begin{tikzpicture}[show background rectangle,scale=.4]
142 \tkzDefPoint(0,0){O}
143 \tkzDefPoint(1,0){I}
144 \tkzDefPoint(10,0){A}
145 \tkzDefPointWith[orthogonal normed,K=4](I,A)
146 \tkzGetPoint{H}
147 \tkzDefMidPoint(O,A) \tkzGetPoint{M}
148 \tkzInterLC(I,H)(M,A)\tkzGetPoints{B}{C}
149 \tkzDrawSegments[color=white,line width=1pt](I,H O,A)
150 \tkzDrawPoints[color=white](O,I,A,B,M)
151 \tkzMarkRightAngle[color=white,line width=1pt](A,I,B)
152 \tkzDrawArc[color=white,line width=1pt,
153 style=dashed](M,A)(O)
154 \tkzLabelSegment[white,right=1ex,pos=.5](I,B){$\sqrt{a}$}
155 \tkzLabelSegment[white,below=1ex,pos=.5](O,I){$1$}
156 \tkzLabelSegment[pos=.6,white,below=1ex](I,A){$a$}
157 \end{tikzpicture}
158 \end{tkzexample}
159
160 \subsubsection{Labels and option : \tkzname{swap}}
161 \begin{tkzexample}[latex=7cm,small]
162 \begin{tikzpicture}[rotate=-60]
163 \tkzSetUpStyle[red,auto]{label style}
164 \tkzDefPoint(0,1){A}
165 \tkzDefPoint(2,4){C}
166 \tkzDefPointWith[orthogonal normed,K=7](C,A)
167 \tkzGetPoint{B}
168 \tkzDefSpcTriangle[orthic](A,B,C){N,O,P}
169 \tkzDefTriangleCenter[circum](A,B,C)
170 \tkzGetPoint{O}
171 \tkzDrawPolygon[green!60!black](A,B,C)
172 \tkzDrawLine[dashed,color=magenta](C,P)
173 \tkzLabelSegment(B,A){$c$}
174 \tkzLabelSegment[swap](B,C){$a$}
175 \tkzLabelSegment[swap](C,A){$b$}
176 \tkzMarkAngles[size=1,
177 color=cyan,mark=|](C,B,A A,C,P)
178 \tkzMarkAngle[size=0.75,
179 color=orange,mark=||](P,C,B)
180 \tkzMarkAngle[size=0.75,
181 color=orange,mark=||](B,A,C)
182 \tkzMarkRightAngles[german](A,C,B B,P,C)
183 \tkzAutoLabelPoints[center = O,dist= .1](A,B,C)
184 \tkzLabelPoint[below left](P){$P$}
185 \end{tikzpicture}
186 \end{tkzexample}
187
188 \hypertarget{tlss}{}
189 \begin{NewMacroBox}{tkzLabelSegments}{\oarg{local options}\parg{pt1,pt2 pt3,pt4 ...}}%
190 The arguments are a two-point couple list. The styles of \TIKZ\ are available for plotting.
191 \end{NewMacroBox}
192
193 \subsubsection{Labels for an isosceles triangle}
194 \begin{tkzexample}[latex=6cm,small]
195 \begin{tikzpicture}[scale=1]
196 \tkzDefPoints{0/0/O,2/2/A,4/0/B,6/2/C}
197 \tkzDrawSegments(O,A A,B)
198 \tkzDrawPoints(O,A,B)
199 \tkzDrawLine(O,B)
200 \tkzLabelSegments[color=red,above=4pt](O,A A,B){$a$}
201 \end{tikzpicture}
202 \end{tkzexample}
203
204 \section{Add labels on a straight line \tkzcname{tkzLabelLine}}%
205
206 \begin{NewMacroBox}{tkzLabelLine}{\oarg{local options}\parg{pt1,pt2}\marg{label}}
207 \begin{tabular}{lll}%
208 arguments & default & definition \\
209 \midrule
210 \TAline{label}{}{\tkzcname{tkzLabelLine(A,B)}\{\$\tkzcname{Delta}\$\}}
211 \bottomrule
212 \end{tabular}
213
214 \begin{tabular}{lll}%
215 options & default & definition \\
216 \midrule
217 \TOline{pos}{.5}{\tkzname{pos} is an option for \TIKZ, but essential in this case\dots}
218 \end{tabular}
219
220 As an option, and in addition to the \tkzname{pos}, you can use all styles of \TIKZ, especially the placement with \tkzname{above}, \tkzname{right}, \dots
221 \end{NewMacroBox}
222
223 \subsubsection{Example with \tkzcname{tkzLabelLine}}
224 An important option is \tkzname{pos}, it's the one that allows you to place the label along the right. The value of \tkzname{pos} can be greater than 1 or negative.
225
226 \begin{tkzexample}[latex=6cm,small]
227 \begin{tikzpicture}
228 \tkzDefPoints{0/0/A,3/0/B,1/1/C}
229 \tkzDefLine[perpendicular=through C,K=-1](A,B)
230 \tkzGetPoint{c}
231 \tkzDrawLines(A,B C,c)
232 \tkzLabelLine[pos=1.25,blue,right](C,c){$(\delta)$}
233 \tkzLabelLine[pos=-0.25,red,left](C,c){again $(\delta)$}
234 \end{tikzpicture}
235 \end{tkzexample}
236
237 \subsection{Label at an angle : \tkzcname{tkzLabelAngle}}
238
239 \begin{NewMacroBox}{tkzLabelAngle}{\oarg{local options}\parg{A,O,B}}%
240 There is only one option, dist (with or without unit), which can be replaced by the TikZ's pos option (without unit for the latter). By default, the value is in centimeters.
241
242 \begin{tabular}{lll}%
243 \toprule
244 options & default & definition \\
245 \midrule
246 \TOline{pos}{1}{ or dist, controls the distance from the top to the label.}
247 \bottomrule
248 \end{tabular}
249
250 \medskip
251 It is possible to move the label with all TikZ options : rotate, shift, below, etc.
252 \end{NewMacroBox}
253
254 \subsubsection{Example author js bibra stackexchange}
255 \begin{tkzexample}[latex=7cm,small]
256 \begin{tikzpicture}[scale=.75]
257 \tkzDefPoint(0,0){C}
258 \tkzDefPoint(20:9){B}
259 \tkzDefPoint(80:5){A}
260 \tkzDefPointsBy[projection=onto B--C](A){a}
261 \tkzDrawPolygon[thick,fill=yellow!15](A,B,C)
262 \tkzDrawSegment[dashed, red](A,a)
263 \tkzDrawSegment[style=red, dashed,
264 dim={$10$,15pt,midway,font=\scriptsize,
265 rotate=90}](A,a)
266 \tkzMarkAngle(B,C,A)
267 \tkzMarkRightAngle(A,a,C)
268 \tkzMarkRightAngle(C,A,B)
269 \tkzFillAngle[fill=blue!20, opacity=0.5](B,C,A)
270 \tkzFillAngle[fill=red!20, opacity=0.5](A,B,C)
271 \tkzLabelAngle[pos=1.25](A,B,C){$\beta$}
272 \tkzLabelAngle[pos=1.25](B,C,A){$\alpha$}
273 \tkzMarkAngle(A,B,C)
274 \tkzDrawPoints(A,B,C)
275 \tkzLabelPoints(B,C)
276 \tkzLabelPoints[above](A)
277 \end{tikzpicture}
278 \end{tkzexample}
279
280 \subsubsection{With \tkzname{pos}}
281 \begin{tkzexample}[latex=7cm,small]
282 \begin{tikzpicture}[scale=.75]
283 \tkzDefPoints{0/0/O,5/0/A,3/4/B}
284 \tkzMarkAngle[size = 4,mark = ||,
285 arc=ll,color = red](A,O,B)%
286 \tkzDrawLines(O,A O,B)
287 \tkzDrawPoints(O,A,B)
288 \tkzLabelAngle[pos=2,draw,circle,
289 fill=blue!10](A,O,B){$\alpha$}
290 \end{tikzpicture}
291 \end{tkzexample}
292
293 \subsubsection{\tkzname{pos} and \tkzcname{tkzLabelAngles}}
294 \begin{tkzexample}[latex=7cm,small]
295 \begin{tikzpicture}[rotate=30]
296 \tkzDefPoint(2,1){S}
297 \tkzDefPoint(7,3){T}
298 \tkzDefPointBy[rotation=center S angle 60](T)
299 \tkzGetPoint{P}
300 \tkzDefLine[bisector,normed](T,S,P)
301 \tkzGetPoint{s}
302 \tkzDrawPoints(S,T,P)
303 \tkzDrawPolygon[color=blue](S,T,P)
304 \tkzDrawLine[dashed,color=blue,add=0 and 3](S,s)
305 \tkzLabelPoint[above right](P){$P$}
306 \tkzLabelPoints(S,T)
307 \tkzMarkAngle[size = 1.8,mark = |,arc=ll,
308 color = blue](T,S,P)
309 \tkzMarkAngle[size = 2.1,mark = |,arc=l,
310 color = blue](T,S,s)
311 \tkzMarkAngle[size = 2.3,mark = |,arc=l,
312 color = blue](s,S,P)
313 \tkzLabelAngle[pos = 1.5](T,S,P){$60^{\circ}$}%
314 \tkzLabelAngles[pos = 2.7](T,S,s s,S,P){%
315 $30^{\circ}$}%
316 \end{tikzpicture}
317 \end{tkzexample}
318
319
320 \begin{NewMacroBox}{tkzLabelAngles}{\oarg{local options}\parg{A,O,B}\parg{A',O',B'}etc.}%
321 With common options, there is a macro for multiple angles.
322 \end{NewMacroBox}
323
324 It finally remains to be able to give a label to designate a circle and if several possibilities are offered, we will see here \tkzcname{tkzLabelCircle}.
325
326 \subsection{Giving a label to a circle}
327 \begin{NewMacroBox}{tkzLabelCircle}{\oarg{tikz options}\parg{O,A}\parg{angle}\marg{label}}%
328 \begin{tabular}{lll}%
329 options & default & definition \\
330 \midrule
331 \TOline{tikz options} {}{circle $O$ center through $A$}
332 \bottomrule
333 \end{tabular}
334
335 \medskip
336 \emph{ We can use the styles from \TIKZ. The label is created and therefore \code{passed} between braces.}
337 \end{NewMacroBox}
338
339 \subsubsection{Example}
340 \begin{tkzexample}[latex=5cm,small]
341 \begin{tikzpicture}
342 \tkzDefPoint(0,0){O} \tkzDefPoint(2,0){N}
343 \tkzDefPointBy[rotation=center O angle 50](N)
344 \tkzGetPoint{M}
345 \tkzDefPointBy[rotation=center O angle -20](N)
346 \tkzGetPoint{P}
347 \tkzDefPointBy[rotation=center O angle 125](N)
348 \tkzGetPoint{P'}
349 \tkzLabelCircle[above=4pt](O,N)(120){$\mathcal{C}$}
350 \tkzDrawCircle(O,M)
351 \tkzFillCircle[color=blue!10,opacity=.4](O,M)
352 \tkzLabelCircle[draw,
353 text width=2cm,text centered,left=24pt](O,M)(-120)%
354 {The circle\\ $\mathcal{C}$}
355 \tkzDrawPoints(M,P)\tkzLabelPoints[right](M,P)
356 \end{tikzpicture}
357 \end{tkzexample}
358
359 \section{Label for an arc}
360 \hypertarget{tls}{}
361 \begin{NewMacroBox}{tkzLabelArc}{\oarg{local options}\parg{pt1,pt2,pt3}\marg{label}}
362 This macro allows you to place a label along an arc. The options are those of \TIKZ\ for example \tkzname{pos}.
363
364 \medskip
365 \begin{tabular}{lll}%%
366 argument & example & definition \\
367 \midrule
368 \TAline{label}{\tkzcname{tkzLabelArc(A,B)\{$5$\}}}{label text}
369 \TAline{(pt1,pt2,pt3)}{(O,A,B)}{label along the arc $\widearc{AB}$}
370 \bottomrule
371 \end{tabular}
372
373 \medskip
374 \begin{tabular}{lll}%
375 options & default & definition \\
376 \midrule
377 \TOline{pos}{.5}{label's position}
378 \end{tabular}
379 \end{NewMacroBox}
380
381 \subsubsection{Label on arc}
382 \begin{tkzexample}[latex=7 cm,small]
383 \begin{tikzpicture}
384 \tkzDefPoint(0,0){O}
385 \pgfmathsetmacro\r{2}
386 \tkzDefPoint(30:\r){A}
387 \tkzDefPoint(85:\r){B}
388 \tkzDrawCircle(O,A)
389 \tkzDrawPoints(B,A,O)
390 \tkzLabelArc[right=2pt](O,A,B){$\widearc{AB}$}
391 \tkzLabelPoints(A,B,O)
392 \end{tikzpicture}
393 \end{tkzexample}
394
395 \endinput