2

I want to draw an arrow like this <---d--->, alongside a line going from x to y. Thanks.

5
  • 4
    Welcome to TeX.SE! Something like \documentclass[tikz,border=3.14mm]{standalone} \begin{document} \begin{tikzpicture} \draw[latex-latex] (0,0) -- ++ (2,0) node[midway,fill=white]{label}; \end{tikzpicture} \end{document}?
    – user121799
    Jan 24, 2019 at 6:55
  • @marmot Yes that works. Thank you. Is drawing alongside, say the line (0,0 --(2,0), as easy as changing the arrow to (0,1)--(2,1) to draw one unit above?
    – jackw11111
    Jan 24, 2019 at 7:00
  • 1
    It depends on whether you have other elements in the picture. If you have no other elements, then the absolute coordinates do not play a role, if you do, you shift relative to these other objects.
    – user121799
    Jan 24, 2019 at 7:16
  • 2
    Welcome to TeX.SE! Can you please show us what you have tried so far? Can you add an screenshot and mark there what you want to change? That would make your question clearer ...
    – Mensch
    Jan 24, 2019 at 8:19
  • 2
    I'm voting to close this question because it is solved in the comments. Jan 24, 2019 at 8:22

2 Answers 2

2

The answer from marmot was :

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
  \begin{tikzpicture}
    \draw[->] (0,0.5) -- (2,0.5);
    \draw[latex-latex] (0,0) -- ++ (2,0) node[midway,fill=white]{label};
  \end{tikzpicture}
\end{document}

enter image description here

But I have a crudely extended this into a command for parameterized use:

\usetikzlibrary{calc}
...
\newcommand{\doublearrowlabel}[5]{
    % accepts a start point, end point, spacing, gradient and label
    \path let \p1=#1 in coordinate (start) at ({\x1 + #3* cos(#4)},{\y1-#3 * sin(#4)});
    \path let \p2=#2 in coordinate (end) at ({\x2 + #3* cos(#4)},{\y2-#3 * sin(#4)});

    \draw[latex-latex]  (start) -- (end) node[midway,fill=white]{#5};
}
...
\draw [->](-0.5,0.8) -- (1,1);
\doublearrowlabel{(-0.5, 0.8)}{(1, 1)}{-5}{75}{First}

\draw [->](-0.5,0.2) -- (-0.8,0.6);
\doublearrowlabel{(-0.5, 0.2)}{(-0.8, 0.6)}{5}{0}{Second}

\draw [->](0.0,-0.3) -- (0.6, 0.3);
\doublearrowlabel{(0.0,-0.3)}{(0.6, 0.3)}{5}{45}{Third}

\draw [->] (0.6, -0.3) -- (0.0,-0.6);
\doublearrowlabel{(0.6, -0.3)}{(0.0,-0.6)}{5}{65}{Fourth}

enter image description here

2

Simply in math-mode you could use the simple code:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\begin{document}
$\longleftarrow \mathrm{label}\longrightarrow $
\end{document}

It is possible to use, for example, also as tikz-arrows the tikz-cd package, you can obtained the desidered output.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[column sep=2cm]
{} \arrow[r, "\text{label}" description, leftrightarrow] & {}
\end{tikzcd}

\begin{tikzcd}[row sep=2cm]
{} \arrow[d, "\text{label}" description, leftrightarrow]\\
{}
\end{tikzcd}

\begin{tikzcd}[row sep=2cm, column sep=2cm]
{} & \\
   & {} \arrow[lu, "\text{label}" description, leftrightarrow]
\end{tikzcd}

\end{document}

You must log in to answer this question.

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