2

I searched for problems like this, but couldn't find any approach. Then, I don't believe this is a duplicated question.

The question is: how to draw section-size arrow marks (like the one shown in the picture) using tikz.

enter image description here

6
  • Sorry, what does section-sized mean? Try \documentclass[tikz,border=3.14mm]{standalone} \begin{document} \begin{tikzpicture} \node (tmp) {$\phi$}; \draw (tmp.north east) -- ++ (-3,0); \draw (tmp.south east) -- ++ (-3,0); \draw[<-] (tmp.north) -- ++ (0,0.5); \draw[<-] (tmp.south) -- ++ (0,-0.5); \end{tikzpicture} \end{document}.
    – user121799
    Dec 18, 2018 at 19:37
  • Hi @marmot. I mean that I would like to draw those couple of arrows that point to each other indicating the size of a section (because is generally used to point diameter of pipes, etc). I know how to draw them separately... but is there a way to draw at once using a simple code?
    – Brasil
    Dec 18, 2018 at 19:42
  • I guess I got most confused by the fact that section has several meanings. So you are talking about diameters, and not the things that come with the \section command, right?
    – user121799
    Dec 18, 2018 at 19:45
  • 1
    Yes. That is exactly what I mean @marmot :)
    – Brasil
    Dec 18, 2018 at 19:46
  • How about this answer?
    – user121799
    Dec 18, 2018 at 19:53

2 Answers 2

6

tikz-dimline was designed for this pourpose. Following code is an example from its documentation.

\documentclass[tikz, border=2mm]{standalone}
\usepackage{tikz-dimline}

\begin{document}
\begin{tikzpicture}[scale=0.5]
\draw[help lines] (-1,-1) grid (4,7);
\draw (0,0) -- (0,4) -- (.5,4) -- (.5,5) -- (1.,5) -- (1.,4) -- (1.5,4) -- (1.5,0)
-- cycle;
\dimline[color=blue,
extension start length=-0.25, extension end length=-0.25]{(2.75,0)}{(2.75,4)}{4.0};
\dimline[color=red,
line style={arrows=dimline reverse-dimline reverse},
label style={above=0.8ex,font=\tiny},
extension start length=1,
extension end length=1]{(0.5,5.6)}{(1.0,5.6)}{0.5};
\end{tikzpicture}
\end{document}

enter image description here

6

An other approach using the To path operation :

\documentclass[border=5mm,tikz]{standalone}
\usetikzlibrary{arrows.meta,calc}
\tikzset{
        diameter/.style={to path={},
                        execute at end to={
                        \draw[Stealth-](\tikztostart)--($(\tikztostart)!-0.5cm!(\tikztotarget)$);
                        \draw[Stealth-](\tikztotarget)--($(\tikztotarget)!-0.5cm!(\tikztostart)$);
                        \path (\tikztostart)--(\tikztotarget) \tikztonodes;
                        },
        }
}
\begin{document}
    \begin{tikzpicture}
        \draw(0,0)--(2,0);
        \draw(0,1)--(2,1);
        \path[diameter] (0.5,0)to node{\(\phi\)}(1,1);

        \path[diameter] (1.5,0)to node{\(\phi\)}(1.5,1);

    \end{tikzpicture}

\end{document}

enter image description here

You must log in to answer this question.

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