0

I'm trying to get a picture like this:

enter image description here

However, I'm having trouble with having the lines spanning between the arrows and having the arrows go exactly to the widths in the picture. This question is similar, but it fills the arrows with the actual lengths of the bars, instead of the $y_2$ and $y_1$ etc that I need.

Here is my MWE so far -- which is nothing close to what I need:

\documentclass{standalone}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
  \draw
  (3,0) coordinate (a) node[right] {$A_1$}
  -- (0,0) coordinate (b) 
  -- (-2,2) coordinate (c) node[above] {$A_2$}
  pic["$\alpha$",draw=MidnightBlue,<->,angle eccentricity=1.2,angle radius=0.8cm] {angle=a--b--c};
    \tkzLabelSegment[below=2pt](a,b){a}
    \tkzLabelSegment[left=2pt](b,c){b}
\end{tikzpicture}
\end{document}

This code results in:

enter image description here

2
  • The example image looks very different from the one you made, are you trying to make an exact copy or simply using ideas from that image?
    – Alenanno
    Apr 12, 2016 at 16:45
  • Hi @Alenanno, yes I'm trying to replicate that image exactly, I just put an MWE to show my "skills" or knowledge of how to use TikZ so far, as I really don't know how to do this. Even if someone could show me some examples I'd be grateful, as I've googled and searched and found nothing close enough :/
    – Alborz
    Apr 12, 2016 at 16:47

1 Answer 1

3

I was going to give you half of it, but I decided to do it all, also because once the half was done, the other half is almost the same, except for some differences.

The "rectangles" are actually done horizontally, but they are enclosed in a scope and this last one rotated, see \begin{scope}[rotate around={30:(O)}]. I think it's easier this way.

The angle is automatically drawn. So to change it, change the rotation of the rectangles.

If something is unclear, feel free to ask in the comments.

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, quotes,angles}

\begin{document}
\begin{tikzpicture}

% Origin
\coordinate (O) at (0,0);

% Upper "rectangle"
\begin{scope}[rotate around={30:(O)}]
\draw[dashed] (O) -- (3,0) coordinate (a);
\draw[ultra thick] (a) -- (5,0) coordinate (b) node[midway, below] {$A_2$};

\draw (O) -- (0,2);
\draw (a) --++ (0,1);
\draw (b) --++ (0,2);

\draw[-{Latex}] (0,.5) -- (0,.5-|a) node[midway, fill=white] {$y_1$};
\draw[-{Latex}] (0,1.5) -- (0,1.5-|b) node[near end, fill=white] {$y_2$};
\end{scope}

% Lower "rectangle"
\begin{scope}[rotate around={-15:(O)}]
\draw[dashed] (O) -- (3.5,0) coordinate (x);
\draw[ultra thick] (x) -- (5.5,0) coordinate (y) node[midway, above] {$A_1$};

\draw (O) -- (0,-2);
\draw (x) --++ (0,-1);
\draw (y) --++ (0,-2);

\draw[-{Latex}] (0,-.5) -- (0,-.5-|x) node[midway, fill=white] {$x_1$};
\draw[-{Latex}] (0,-1.5) -- (0,-1.5-|y) node[near end, fill=white] {$x_2$};
\end{scope}

% Angle (automatic)
\path (b) -- (O) -- (y) 
  pic["$\alpha$",draw=red,<->,angle eccentricity=1.2,angle radius=2cm] {angle=y--O--b};

\end{tikzpicture}
\end{document}
6
  • Wow thank you so much, I really appreciate this!
    – Alborz
    Apr 12, 2016 at 17:15
  • I did have one question, how did you get the lines between the arrows? What part of the code generates those lines?
    – Alborz
    Apr 12, 2016 at 17:22
  • @Alborz which lines are you referring to? The ones that touch the arrow tips?
    – Alenanno
    Apr 12, 2016 at 17:23
  • yes exactly, that emanate from the ends of A1 and A2 upwards
    – Alborz
    Apr 12, 2016 at 17:26
  • 1
    @Alborz for example: \draw (a) --++ (0,1); \draw (b) --++ (0,2);
    – Alenanno
    Apr 12, 2016 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .