Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am learning TikZ and am confused about two apparent completely different ways to go about things, although they seem completely compatible and intermixable:

\begin{tikzpicture}
\draw[color=black] (20,20) -- (100,20);
% vs
\tkzDrawSegments((20,20),(100,20))
\end{tikzpicture}

I'm quite sure the second thing is wrong (please correct to fix this). The first way seems way more powerful (you've got nodes and all), but the second way has stuff like tkzMarkAngle which seems painful to do the first way.

What is the difference and how would I do a "simple thing" like tkzMarkAngle using paths?

share|improve this question
2  
\tkzDrawSegment is not a "native" tikz command. It has been implemented in another package (or perhaps in the preamble of the tex document). In this case it probably comes from tkz-euclide. Those "external" commands not neccesarly adhere to tikz conventions in syntax. –  JLDiaz Jan 18 '13 at 13:13
add comment

1 Answer

I don't know if it is possible to give a precise consideration on which package is more powerful (TikZ or the tkz bundle): what is true is that they have a different syntax, but I think there are cases in which TikZ provides a simpler programming solution and others when tkz is more straightforward.

For example, the macro \tkzMarkAngle, is one of the latter case. You could find the code of the macro typing in the shell:

gedit $(kpsewhich tkz-obj-angles.tex)

The following document tries to replicate the same picture with both packages and with a similar programming structure:

\documentclass[a4paper,11pt]{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usepackage{tkzexample}
% to display picture and code
\usetkzobj{all}

\begin{document}
tkz-based solution:
\begin{center}
\begin{tkzexample}[latex=4.5cm]
\begin{tikzpicture}
\tkzDefPoint(0,0){O} 
\tkzDefPoint(2,2){A}
\tkzDefPoint(-2,3){B}
\tkzDrawSegment[thick](O,A)
\tkzDrawSegment[thick](O,B)
% equivalent: \tkzDrawVectors(O,A O,B)
\tkzMarkAngle[fill= yellow,%
 opacity=.5](A,O,B)
\end{tikzpicture}
\end{tkzexample}
\end{center}

Ti\textit{k}Z-based solution:
\begin{center}
\begin{tkzexample}[latex=4.5cm]
\begin{tikzpicture}
\coordinate (O) at (0,0);
\coordinate (A) at (2,2);
\coordinate (B) at (-2,3);
\draw[thick] (B)--(O) 
 node[coordinate,pos=0.7](x-b){};
\draw[thick] (A)--(O) 
 node[coordinate,pos=0.625](x-a){};
\draw[fill=yellow,opacity=.5] 
 (O)--(x-b)  arc (125:38:0.95cm) -- (O);
\end{tikzpicture}
\end{tkzexample}
\end{center}

\end{document}

which provides:

enter image description here

As you can see, the second picture is not precise as the first one, because inside the definition of \tkzMarkAngle there is the exact computation for that. Not that you couldn't do the calculus with pure TikZ, but you need to complicate the code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.