2

The code is below.

\documentclass[12pt,letterpaper]{article}    
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}

\usepackage{tikz} % for drawing pictures \usetikzlibrary{arrows.meta, chains, positioning, quotes, shapes.geometric, arrows} \begin{document}

\begin{center} \begin{tikzpicture}[auto, node distance = 15mm and 19mm, start chain = going right, arr/.style = {->},>=Latex, block/.style = {draw, minimum height=3em, minimum width=4em,align=center,fill=blue!20}, sum/.style = {circle, draw, node contents={}},
] \begin{scope}[nodes={on chain, join=by arr}]
\coordinate (in);

            \node (n4) [block] {$K_m = 2 \times 10^{-1}$ \\ $N mV^{-1}$};

        \node (n5) [block] {$K_s = 5 \times 10^{-2}$ \\ $rad \hspace{1mm} N^{-1} m^{-1}$};
            \coordinate (out);

         \path (n4) to [below, pos=0.5,"$T$"] (n5)   (out) ;
          \path (n4) to [below, pos=0.5,"$V$"]  (in) ;

            \path (n5) to [below, pos=0.5,"$\theta$"]  (out) ;

\end{tikzpicture} \end{center}

\end{document}

This picture below is what I got from code above.

enter image description here

This below is what I want to achieve.

enter image description here

kile
  • 655

2 Answers2

4

Sorry, I hadn't spare time earlier ...

A possible solution can be:

\documentclass[12pt,letterpaper]{article}
\usepackage[hmargin=20mm,vmargin=30mm]{geometry}

\usepackage{siunitx} \usepackage{tikz} % for drawing pictures \usetikzlibrary{arrows.meta, decorations.markings, positioning, quotes, shapes.geometric}

\begin{document} \begin{center} \begin{tikzpicture}[auto, node distance = 1mm and 19mm, block/.style = {draw, fill=blue!20, minimum height=3em, minimum width=4em, align=center, label=below:#1 }, sum/.style = {circle, draw, node contents={}}, % arr/.style = {-{Stealth[scale=1.6]}}, ->-/.style = {decoration = {markings,mark=at position 0.5 with {\arrow[scale=1.6]{Stealth}}}, postaction={decorate}}, every edge quotes/.append style = {anchor=center, align=center} ] \coordinate (in); \node (n4) [block=Motor, right=of in] {$K_m=2\times 10^{-1}$ \ \unit{N mV^{-1}}}; \node (n5) [block=Spring, right=of n4] {$K_s=5\times 10^{-2}$ \ \unit{\radian\per\newton\per\metre}}; \coordinate[right=of n5] (out); \draw (in) edge [->-,"$V$\ Volts"] (n4) (n4) edge [->-,"$T$\ \unit{\newton\meter\second}"] (n5) (n5) edge [arr, "$\theta$\ rad"] (out); \end{tikzpicture} \end{center} \end{document}

enter image description here

Addendum: A case when nodes "block" are in chain.

\usepackage[hmargin=20mm,vmargin=30mm]{geometry}

\usepackage{siunitx} \usepackage{tikz} \usetikzlibrary{arrows.meta, chains, % added decorations.markings, positioning, quotes, shapes.geometric}

\begin{document} \begin{center} \begin{tikzpicture}[auto, node distance = 1mm and 19mm, start chain = going right, CB/.style = {draw, fill=blue!20, % ChainBlock minimum height=3em, minimum width=4em, align=center, on chain, % added label=below:#1 }, sum/.style = {circle, draw, node contents={}}, % arr/.style = {-{Stealth[scale=1.6]}}, ->-/.style = {decoration = {markings,mark=at position 0.5 with {\arrow[scale=1.6]{Stealth}}}, postaction={decorate}}, every edge quotes/.append style = {anchor=center, align=center} ] \coordinate[on chain] (in); % added option "on chain" \node (n4) [CB=Motor] {$K_m=2\times 10^{-1}$ \ \unit{N mV^{-1}}}; \node (n5) [CB=Spring]{$K_s=5\times 10^{-2}$ \ \unit{\radian\per\newton\per\metre}}; \coordinate[on chain] (out); % added option "on chain" \draw (in) edge [->-,"$V$\ Volts"] (n4) (n4) edge [->-,"$T$\ \unit{\newton\meter\second}"] (n5) (n5) edge [arr, "$\theta$\ rad"] (out); \end{tikzpicture} \end{center} \end{document}

Result is the same as before.

Zarko
  • 296,517
  • As I'm curious: how can we have the same stealth for the very last arrow? – NBur Jan 19 '23 at 15:41
  • 1
    @NBur, me too ... ah in arr style I forgot to add the same scaling Stealth as at ->-. Corrected now. Thank you very much to point me on this. – Zarko Jan 19 '23 at 16:04
3

I added the siunitx package and the calc library.

\documentclass[12pt,letterpaper]{article}    
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}

\usepackage{tikz} % for drawing pictures \usetikzlibrary{arrows.meta, calc, chains, positioning, quotes, shapes.geometric, arrows} \usepackage{siunitx}

\begin{document} \begin{center} \begin{tikzpicture}[auto, node distance = 15mm and 19mm, start chain = going right, arr/.style = {->},>=Latex, block/.style = {draw, minimum height=3em, minimum width=4em,align=center,fill=blue!20}, sum/.style = {circle, draw, node contents={}},
] \begin{scope}[nodes={on chain, join=by arr}]
\coordinate (in);

    \node (n4) [block] {$K_m = \num{2e-1}$\\ \unit{\newton\meter\per\volt}};

    \node (n5) [block] {$K_s = \num{5e-2}$ \\ \unit{\radian\per\newton\per\metre}};
    \coordinate (out);

  \end{scope}
  \node [below=1pt of n4] {Motor};
  \node [below=1pt of n5] {Spring};
  \node at ($(in)!.5!(n4.west)$) [label={above:$V$}, label={below:\unit{\volt}}] {};
  \node at ($(n4.east)!.5!(n5.west)$) [label={above:$T$}, label={below:\unit{\newton\meter}}] {};
  \node at ($(n5.east)!.5!(out)$) [label={above:$\theta$}, label={below:\unit{\radian}}] {};
\end{tikzpicture}

\end{center} \end{document}

enter image description here

NBur
  • 4,326
  • 10
  • 27
  • Could you let the arrow in the middle of line? because mine is at the end of the line but the one from the desired one is in the middle – kile Jan 19 '23 at 11:59
  • @kile you should accept Zarko's answer as it solve this point! – NBur Jan 19 '23 at 15:43