Graphics, Figures & TablesTiKz (\foreach): reversing arrows

Information and discussion about graphics, figures & tables in LaTeX documents.
Sundial
Posts: 57
Joined: Thu Apr 19, 2012 7:28 pm

TiKz (\foreach): reversing arrows

Post by Sundial »

Gift to Latex community forum, for the help received today. Fine drifts quickly applied in next code. Best wishes

Code: Select all

% --------- trench.tex -------- Apr.20,2015  
% Scheme of loads for soil trench
%      (1-vertical; 2-vertical, shifted from origin along x-axis
%       3-horizontal)
\documentclass{article}
\usepackage{tikz} 
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{center}
\setlength\PreviewBorder{10pt}

\tikzstyle{axis} = [-latex,blue!55]

\tikzstyle{two}=[x={(0.75cm,0cm)},y={(0cm,0.75cm)}]

\begin{document}
\begin{center}
\begin{tikzpicture}[two]
\coordinate (O) at (0,0);
\draw[axis] (O) -- ++(8,0) node[right] {$x$};
\draw[axis] (O) -- ++(0,6) node[above] {$y$};

% 1) --- right triangle loads + wall  ---- 
\foreach \y in {0, 0.25,...,4.5} { % full height triangle shaped arrows
 \draw[-latex] (6-\y/2.5,\y) -- (4,\y);}
% Contour
\draw [red] (4,5) -- (6,0); % closing queues arrows
\draw [blue] (4,5) -- (4, 0); % drawing wall
%
% 2) --- left load triangle + wall on y-axis ----
\foreach \y in {0, 0.25,...,4.5} { % full height triangle shaped arrows
\draw[-latex] (-2+\y/2.5,\y) -- (0,\y);}
% Contour
\draw [red] (0,5) -- (-2,0); % closing queues arrows

% 3) trench lines
\draw [blue] (4,5) -- (6, 5);
\draw [blue] (0,5) -- (-2, 5);

% 4) soil reaction
 \foreach \x in {0,0.25,...,4} {
 \draw[-latex] (\x,-1.5) -- ++(0,1.5);  }
% Contour
\draw [red] (0,-1.5) -- (4,-1.5); % closing vertical arrows queues

% 
% Caption
\draw (0.2,7) -- ++(0,0) node[right,midway] {Loads on Trench};

\end{tikzpicture} 
\end{center}
\end{document}
%
% ---- EOF: trench.tex ---------- 
%
Attachments
02.png
02.png (17.56 KiB) Viewed 3290 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Sundial
Posts: 57
Joined: Thu Apr 19, 2012 7:28 pm

TiKz (\foreach): reversing arrows

Post by Sundial »

One more help, please!
In some frequent circumstances [application of Mohr's theorems] they need to have the beam loaded with parabolic shape, as shown in the att'd code+screenshot. Thanks in advance for drifts.

Code: Select all

% --------- d2.tex --------- Apr.21,2015 ---------
\documentclass{article}
\usepackage{tikz}             

\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{center}
\setlength\PreviewBorder{10pt}%

\tikzstyle{load}   = [thick,-latex]
\tikzstyle{stress} = [-latex]
\tikzstyle{dim}    = [latex-latex]
\tikzstyle{axis}   = [-latex,blue!55]

\tikzstyle{two}=[x={(1cm,0cm)},y={(0cm,1cm)}]

\begin{document}
\begin{center}
  \begin{tikzpicture}[two]
        \coordinate (O) at (0,0);
        \draw[axis] (O) -- ++(6,0) node[right] {$x$};
        \draw[axis] (O) -- ++(0,6) node[above] {$y$};
%
    \foreach \x in {0,0.25,...,4} {
      \draw[-latex] (\x,5.5) -- ++(0,-0.5); % To be replaced with parabolic shape
    }
    \draw (0,5.5) -- ++(4,0); % closing arrows to be modified in parabolic diagram 
    \draw (0,5) -- ++(4,0);  % beam
%   
    \draw[dim] (4.5,0) -- ++(0,5) node[midway,right] {$h$}; % column dimension
    \draw (4.25,5) -- ++(0.5,0); 
%    
    \draw[dim] (0,-0.5) -- ++(4,0) node[midway,above] {$\ell$}; % beam dimension
    \draw (4,-0.75) -- ++(0,0.5); 
    \draw (0,-0.75) -- ++(0,0.5); 
     
  \end{tikzpicture} %
\end{center}
\end{document}
%
% ---- EOF: d2.tex ----
Attachments
00.png
00.png (60.38 KiB) Viewed 3280 times
Sundial
Posts: 57
Joined: Thu Apr 19, 2012 7:28 pm

TiKz (\foreach): reversing arrows

Post by Sundial »

Last step to finalize the matter! Cheers

Code: Select all

% --------- d3.tex --------- Apr.22,2015 ---------
\documentclass{article}
\usepackage{tikz}             

\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{center}
\setlength\PreviewBorder{10pt}%

\tikzstyle{load}   = [thick,-latex]
\tikzstyle{stress} = [-latex]
\tikzstyle{dim}    = [latex-latex]
\tikzstyle{axis}   = [-latex,blue!55]

\tikzstyle{two}=[x={(1cm,0cm)},y={(0cm,1cm)}]

\begin{document}
\begin{center}
  \begin{tikzpicture}[two]
        \coordinate (O) at (0,0);
        \draw[axis] (O) -- ++(6,0) node[right] {$x$};
        \draw[axis] (O) -- ++(0,6) node[above] {$y$};
%
%  p value amplified
    \foreach \x in {0.25,0.5,...,3.75} {%     
       \draw[-latex] (\x,4*\x*3/8-\x*\x*3/8+5) -- (\x,5); 
     }

% Tentative to close arrows queues ... it doesn't produce nothing!
%    \foreach \x in {0,0.25,...,4} {%   
%     \draw (\x,4*\x*3/8-\x*\x*3/8+5); 
%     }


    \draw (0,5) -- ++(4,0);  % beam
%   
    \draw[dim] (4.5,0) -- ++(0,5) node[midway,right] {$h$}; % column dimension
    \draw (4.25,5) -- ++(0.5,0); 
%    
    \draw[dim] (0,-0.5) -- ++(4,0) node[midway,above] {$\ell$}; % beam dimension
    \draw (4,-0.75) -- ++(0,0.5); 
    \draw (0,-0.75) -- ++(0,0.5); 
     
  \end{tikzpicture} %
\end{center}
\end{document}
%
% ---- EOF: d3.tex ----
Attachments
03.png
03.png (11.95 KiB) Viewed 3274 times
Sundial
Posts: 57
Joined: Thu Apr 19, 2012 7:28 pm

TiKz (\foreach): reversing arrows

Post by Sundial »

End of story ... via parabola bend. All the best!

Code: Select all

% --------- d4.tex --------- Apr.22,2015 ---------
\documentclass{article}
\usepackage{tikz}             

\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{center}
\setlength\PreviewBorder{10pt}%

\tikzstyle{load}   = [thick,-latex]
\tikzstyle{stress} = [-latex]
\tikzstyle{dim}    = [latex-latex]
\tikzstyle{axis}   = [-latex,blue!55]

\tikzstyle{two}=[x={(1cm,0cm)},y={(0cm,1cm)}]

\begin{document}
\begin{center}
  \begin{tikzpicture}[two]
        \coordinate (O) at (0,0);
        \draw[axis] (O) -- ++(6,0) node[right] {$x$};
        \draw[axis] (O) -- ++(0,6) node[above] {$y$};
%
%  p value amplified
    \foreach \x in {0.25,0.5,...,3.75} {%     
       \draw[-latex] (\x,4*\x*3/8-\x*\x*3/8+5) -- (\x,5); 
     }

% Contour of arrows queues
   \draw [red] (0,5) parabola bend (2,6.5) (4,5); 

    \draw (0,5) -- ++(4,0);  % beam
%   
    \draw[dim] (4.5,0) -- ++(0,5) node[midway,right] {$h$}; % column dimension
    \draw (4.25,5) -- ++(0.5,0); 
%    
    \draw[dim] (0,-0.5) -- ++(4,0) node[midway,above] {$\ell$}; % beam dimension
    \draw (4,-0.75) -- ++(0,0.5); 
    \draw (0,-0.75) -- ++(0,0.5); 
     
  \end{tikzpicture} %
\end{center}
\end{document}
%
% ---- EOF: d4.tex ----
Attachments
04.png
04.png (12.7 KiB) Viewed 3269 times
Post Reply