1

I would like to draw a straight line down from (P) to y = -2cm. I tried issuing \draw[rotate = -45, xshift = 0.1cm, >=stealth, |<->|] (P) -- +(0, -1cm); but this doesn't cancel the initial rotation.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate = 45]
  \draw (-0.5cm, -1cm) rectangle (0.5cm, -2cm) coordinate (P);
\end{scope}
\end{tikzpicture}
\end{document}

Edit:

In my initial workings, I used (0.5cm, -2cm) and not the label (P). The coordinate values produce a different result and resulted in a new question: Tikz: rotating point coordinates over a labelled coordinate

  • @GonzaloMedina Paul Gessler pointed that out. I asked a new question because it doesn't work if we use (0.5, 2) instead of P. – dustin May 15 '14 at 17:23
3

You can do the \draw outside the scope:

enter image description here

Code:

\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[rotate = 45]
  \draw (-0.5cm, -1cm) rectangle (0.5cm, -2cm) coordinate (P);
\end{scope}
  \draw[>=stealth, |<->|] (P) -- +(0, -1cm);
\end{tikzpicture}
\end{document}
  • So what I take from this is if I label a point in a scope, that label will be defined by the overall action on it not just its point location, correct? – dustin May 15 '14 at 17:06
  • 1
    @dustin, this appears to give the exact same result I got using your \draw[rotate = -45, xshift = 0.1cm, >=stealth, |<->|] (P) -- +(0, -1cm); inside the scope. Just for my own knowledge, what is different here? – Paul Gessler May 15 '14 at 17:09
  • @PaulGessler you are right. If we don't name the coordinate and just use (0.5cm, -2cm), it doesn't work though. That is why I was under the impression the opposite rotation wouldn't work. – dustin May 15 '14 at 17:12
  • @PaulGessler see my new question about this. tex.stackexchange.com/questions/177421/… – dustin May 15 '14 at 17:19
0
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[xshift=3cm,rotate = 45]
  \draw (-0.5cm, -1cm) rectangle (0.5cm, -2cm) coordinate (P);
  \draw[>=stealth,line width=2pt, blue, |<->|] (P) -- +(-135:1cm);
  \draw[>=stealth, |<->|] (0.5cm, -2cm) -- +(-135:1cm);    %%% -90 adds to -45 so -135
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

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.