3

Currently I'm learning TiKZ and was following the "Karl drawing unit circle for his students" example. When I got to the point where we draw the sine line, the manual said we could use

\draw[red,very thick] (30:1cm |- 0,0)

I prefered this to

\draw[red,very thick] (30:1cm) -- +(0, -0.5)

as it relies on a specific value and is not very general. However, the latter works (draws a nice red sine line) but the former doesn't. How can I resovle this?

Thanks in advance?

  • It might help to see where you actually want to use this command, because maybe there might be a more appropriate way to approach the same case. – Alenanno Mar 25 '16 at 15:03
  • 1
    I think what you want is \draw[red,very thick] (30:1cm) -- (30:1cm |- 0,0);. Please see my edited answer. – erik Mar 25 '16 at 15:16
  • "Does not work" does not have a meaning. If you get an error you should post the error. If you get an unexpected output you should write both the wrong output you get and the expected output. The next time you have a question review all your "does not work" expressions and replace them with appropriate descriptions of what "does not work" and how it "is not working". – Bakuriu Mar 25 '16 at 19:24
  • I mean, it doesn't draw the same line as the 2nd command. Anyway this is resolved now. – naiveai Mar 26 '16 at 1:35
7

As described in the manual, (30:1cm |- 0,0) is a coordinate straight down from the coordinate (30:1cm). What you have so far is one of the coordinates, so you need to supply the other.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[scale=3]
\clip (-0.1,-0.2) rectangle (1.1,0.75); 
\draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4); 
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\draw[red,very thick] (30:1cm) -- (30:1cm |- 0,0);
\end{tikzpicture}
\end{document}

enter image description here

  • Oh, so it specifies a coordinate - not a line. Yes, this works. – naiveai Mar 25 '16 at 16:16

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.