I'm a beginner on TikZ package and trying to draw two triangles on a non-horizontal line, as shown below.

enter image description here

Is there any way to draw the triangles first on a straight line and then rotate them?

  • 2
    Welcome to TexSE. The simple answer is "yes, as explained in the manual". A quick search of the manual with the string "rotate" would show you that \draw[rotate=30]... might give you a starting point. In general you will get more help here (a) if you ask a specific question about how to do something and (b) you show us what you have already tried in the form of a working example we can compile. – Thruston Oct 1 '16 at 13:53

A starting point. The code duplication for the two triangles is avoided by a \foreach loop.

    myarrowtip/.tip={Triangle[length=12pt, width=8pt]},
    myarrow/.style={draw={#1},line width=2.5pt, -{myarrowtip}},
    (\AngleS:9cm) node (s) {$s$}
    (0, 0) --
    coordinate[pos=.22] (si)
    coordinate[pos=.66] (sf)
  \foreach \start/\ssub in {si/i, sf/f} {
      (\start) ++(\AngleS:\RadiusTheta)
      arc (\AngleS:\AngleS + \AngleTheta:\RadiusTheta)
      (\start) ++(\AngleS + \AngleTheta/2:\RadiusTheta + 1.5ex)
      node {$\theta$}
      (\start) -- ++(\AngleS:\ArrowLen)
      coordinate (tmpA)
      node[below] {$\vec F_s$}
      (\start) -- ++(\AngleS + \AngleTheta:{\ArrowLen/cos(\AngleTheta)})
      coordinate (tmpB)
      node[left] {$\vec F$}
    \draw[dashed] (tmpA) -- (tmpB);
      (\start) circle[]
      ++(\AngleS - 90:1em) node {$s_{\ssub}$}
    (si) ++(\AngleS - 90:2em)
    -- node[below] {$\Delta \vec r$}
    ++(\AngleS:{(.66 - .22) * 9cm})


  • Regarding the original question, whether it is possible to draw everything horizontally and then rotate it: Just replace all occurrences of \AngleS in the \draw commands by zero, and put the commands into a scope environment starting with \begin{scope}[rotate=\AngleS] and terminating with \end{scope}. This makes the code even a bit simpler (though it is already quite compact). – gernot Oct 1 '16 at 16:23
  • I suppose it also rotates the labels? – Bernard Oct 1 '16 at 17:15
  • @Bernard No. It just rotates the coordinates. If you want to rotate anything, then the rotation needs to be applied to the canvas: transform canvas={rotate=\AngleS}. – Heiko Oberdiek Oct 1 '16 at 17:29

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.