2

I have a figure like the image:

enter image description here

And I want to draw these arrows like this image:

enter image description here

This is my code:

\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{figure}[h]
        \centering
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        \begin{tikzpicture}
          %Definindo os vertices
          %Vertice da reta da esquerda
          \tkzDefPoint (0,0){A}
          \tkzDefPoint (0,8){B}
          %Vertices U1
          \tkzDefPoint (1,0){C}
          \tkzDefPoint (1,1.5){D}
          %Vertices U2
          \tkzDefPoint (4,6){E}
          \tkzDefPoint (4,8){F}
          %Chao1
          \tkzDefPoint (-1.5,0){G}
          \tkzDefPoint (6,0){H}   
          %Desenhando as retas
          \draw (A) -- (B);
          \draw (C) -- (D);
          \draw (D) -- (E);
          \draw (E) -- (F);
          \draw (G) -- (H);
          \end{tikzpicture}
        \end{figure}
  • You can make your code a little more efficient by combining some of the \draw commands: \draw (C) -- (D) -- (E) -- (F); – Annie Carter May 30 '18 at 1:23
  • One way to get your arrows is to define their endpoints, as you have done with the other lines, and then put in lines tipped with arrows with code like \draw[-stealth] (P) -- (Q); – Annie Carter May 30 '18 at 1:26
0

I will not change the style you used to draw the diagram (I see no point in using tkz-euclide here), I will just add the arrows you want. The intersections library comes in handy to calculate the points of arrow tips. You draw long-enough equally spaced horizontal rays and let the library calculate their intersection points with the zigzag line. Then, you draw the arrows starting from the AB line towards the right till the corresponding intersection point.

\documentclass[10pt,a4paper]{article}
\usepackage{tkz-euclide}  % internally loads tikz 
\usetkzobj{all}
\usetikzlibrary{intersections,arrows.meta}
\begin{document}

\begin{figure}[!htb]
  \centering
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \begin{tikzpicture}[>= {Stealth[scale=2.5,inset=0pt,angle'=20]}]
  %Definindo os vertices
  %Vertice da reta da esquerda
  \tkzDefPoint (0,0){A}
  \tkzDefPoint (0,8){B}
  %Vertices U1
  \tkzDefPoint (1,0){C}
  \tkzDefPoint (1,1.5){D}
  %Vertices U2
  \tkzDefPoint (4,6){E}
  \tkzDefPoint (4,8){F}
  %Chao1
  \tkzDefPoint (-1.5,0){G}
  \tkzDefPoint (6,0){H}   
  %Desenhando as retas
  \draw (A) -- (B) (G) -- (H);
  \draw[name path=zigzag] (C) -- (D) -- (E) -- (F);          
  \foreach \y in {0.5,1.3,...,7.8}{
    \path[name path=ray] (0,\y) -- (9,\y);
    \path[name intersections={of=zigzag and ray,by=p}];
    \draw[->] (0,\y) -- (p);
  }       
  \end{tikzpicture}
\end{figure}

\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.