3

I was reading into the forums about drawing with TIKZ, as recently I found myself in need to create drawings in my documents - I'm a teacher and I'm trying to use XeLaTeX to create worksheets and also texts for my students to read, and since they're in middle school I figured that using images would help them understand the ideas better, for both 2d and 3d geometry. Today I heard about the tkz-euler package, but when I loaded it in my preamble, I got errors. So, I copied a code from this post and loaded my preamble with it:

This is the code I've got:

\RequirePackage[l2tabu, orthodox]{nag}
\documentclass[a4paper,12pt]{article}
\usepackage[hmargin=2cm,vmargin=2cm,bmargin=2cm]{geometry}
\usepackage[brazil]{babel}
\usepackage{fontspec}
\usepackage{units,gensymb}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{comment}
\usepackage{tkz-euclide}
%\usetikzlibrary{shapes.geometric}
%\usetikzlibrary{calc}
\usetkzobj{all}
\usepackage{pgfplots}

\usepackage{siunitx}
\usepackage{icomma}
\usepackage{newtxmath} %Para fonte times (usar text para texto)
\sisetup{output-decimal-marker = {,}} %Vírgula como separador decimal no siunitx
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=2pt] (char) {#1};}} %Para fazer números em círculos    
\let\sin\relax\DeclareMathOperator\sin{sen}

\begin{document}
\begin{tikzpicture}

\tkzDefPoint(0,0){A}  \tkzLabelPoint[below left](A){A}
\tkzDefPoint(3,0){B}  \tkzLabelPoint[below right](B){B}
\tkzDefSquare(A,B)    \tkzGetPoints{C}{D}
\tkzDrawSquare(A,B)
\tkzLabelPoint[above right](C){C} \tkzLabelPoint[above left](D){D}
\tkzDefMidPoint(C,D) \tkzGetPoint{E}  \tkzLabelPoint[above](E){E}
\tkzDefMidPoint(B,C) \tkzGetPoint{F}  \tkzLabelPoint[right](F){F}
\tkzDrawSegments(A,E E,F A,F)
%\tkzDrawPolygon(A,E,F)
\tkzDrawPoints[fill=black](E,F)
\tkzMarkAngle[fill=red,%
             %size=0.4,   % for small squares you may want to use this
             opacity=0.4](F,A,E)
\tkzLabelAngle[pos=1.2](E,A,F){$\alpha$}

\end{tikzpicture}
\end{document}

At first I thought it was a compatibility problem about TIKZ vs. tkz-euclide, that's why TIKZ isn't even in the document, but I've come to realize that the very first line was causing the errors, so commenting out \RequirePackage[l2tabu, orthodox]{nag} worked.

My problem is that that I got that line a while ago and can't remember why, so I am kinda unsure whether to delete it or not. So:

  1. What is the function of \RequirePackage[l2tabu, orthodox]{nag}?
  2. Is it a good move to swap TIKZfor tkz-euclid or do they complete each other? I also have use for tikz-3dplot, what packages should I keep?
  3. The pgfplots package is there since I saw it where I copied the code from. What's it's function in this situation?

Thanks in advance!

  • Remove the first line. The nag package is supposed to warn about usage of deprecated constructs. Useless, in my opinion, and harmful as it changes several things, with the risk of breaking them like in this case. Don't load packages until you know that you need them; probably the document you copied the preamble from needed pgfplots. Do you? – egreg Oct 18 '15 at 22:22
  • 1
    I don't think it is useless but its usefulness is limited. It can be convenient if, say, you want to check an older source for deprecated syntax when updating it. But I'd only ever include it temporarily, look for the warnings I'm interested in, make changes, recheck and then delete it when it has done its job. If you don't even know what it is for, loading it is of no use whatsoever since you aren't going to read its warnings anyway. pgfplots is not doing anything in this situation. tkz-euclid requires TikZ as far as I know. Keep packages you use and only packages you use. – cfr Oct 18 '15 at 22:27
2
  1. The point of the nag package is to tell the user if he is doing something that is considered bad practice or obsolete. Now, it wont catch all such things of course, but it is supposed to catch a lot of the things described in l2tabu. Exactly why it causes a conflict here I cannot say though.

  2. tkz-euclide loads TikZ. tkz-euclide is designed for creating figures like the one you've made, while TikZ is more general. You can do whatever tkz-euclide can with just TikZ, but in some cases the former has much easier ways of achieving certain types of constructions.

    In other words, if you like tkz-euclide, keep it. It doesn't prevent you from using TikZ, nor (I think) tikz-3dplot.

  3. pgfplots does precisely nothing here, as far as I can see, its features aren't used at all.

Also, as you're loading siunitx I don't think there is any point in loading units.

  • Since tkz-euclide loads TikZ, am I able to use it as I was using TikZ? For example, I have a line from A to B with TikZ code, is it the same for tkz-euclide? – Guilherme Vargas Oct 18 '15 at 22:40
  • 1
    @GuilhermeVargas I don't really understand what you mean. The syntax for drawing a line from A to B is different, if that's what you mean, as is everything else. But because tkz-euclide is kind of a "front end" for TikZ, its code is placed in a tikzpicture environment (as you have in your code), and you can also mix code. For example, in your code you can use \draw (A) -- (B); (normal TikZ syntax) even though the points A and B are defined with \tkzDefPoint (tkz-euclide syntax). – Torbjørn T. Oct 18 '15 at 22:58
  • Yes, that's what I meant, thank you, my poor english made it tough to get my point through at first. But do you mean I can mix the syntaxes by using both tikz and tkz-euclide packages, right? – Guilherme Vargas Oct 18 '15 at 23:11
  • @GuilhermeVargas To use tkz-euclide syntax you need to explicitly say \usepackage{tkz-euclide}. This will implicitly load TikZ, so you don't have to say \usepackage{tikz} in addition. What I mean is that something like \documentclass{article} \usepackage{tkz-euclide} \begin{document} \begin{tikzpicture} \tkzDefPoint(0,0){A}\tkzDefPoint(1,1){B} \draw (A) -- (B); \end{tikzpicture} \end{document} works. The points A and B are defined using tkz-euclide features, but the line is drawn with the normal TikZ \draw. – Torbjørn T. Oct 19 '15 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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