2

My code is

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{tikzpicture}
    \node (0,0) {$M = \frac{A+B}{C \times D} + F + G$};
    \draw[thick, red, ->] (-0.5,0.5) -- (-.35,2);
    \draw[thick, red, ->] (0,0.5) -- (-.15,2);
    \draw[thick, ->] (0.7,-0.25) -- (1,-2);
    \draw[thick, ->] (1.3,-0.25) -- (1.1,-2);
    \node[red, ellipse,draw] (-.2,2.5) {method 1};
    \node[ellipse,draw] (1.1,-2.5) {method 2};
\end{tikzpicture}

\end{document}

And the result is

enter image description here

The result I want is

enter image description here

I'm not sure why the nodes aren't positioning correctly, because I think the coordinates given are right. If someone could help (and even better, explain) that'd be great.

Bonus question: How do you make it so just the node outline and not the text is red?

Thanks!

  • 1
    you are missing the at before the coordinates – percusse Aug 16 '16 at 23:54
  • @percusse, wow, I can't believe I made that mistake! =) Post that as an answer and I will accept it. (I think I'll also add something else to my question, first.) Thank you so much! – heather Aug 16 '16 at 23:56
  • Use draw=red instead of red, draw, .... Text will stay black. – Alenanno Aug 17 '16 at 0:06
  • @Alenanno, thanks so much! If you or percusse write an answer, I will accept it. – heather Aug 17 '16 at 0:07
3

The first question is just a typo, that is, at keyword was missing before the coordinates so it was understood as the name of the node. The bonus question is actually comes to the fact that when a standalone color is given it sets some kind of a generic \pgf....@current@color@.... for everything (behind the scenes it modifies the color . using the xcolor syntax)

A more selective color syntax is using the dedicated key in the path declaration such as

\draw[draw=red,text=blue] ...

That only modifies the specific property.

  • @heather my pleasure – percusse Aug 17 '16 at 0:09

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.