4

The following MWE produces an edge between two nodes with label x above and label y below the edge:

enter image description here

I draw the edge twice to achieve this. Is there a more elegant way?

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {};
\node (b) at (2,0) {};
\draw (a) to node[above] {x} (b);
\draw[fill=none] (a) to node[below] {y} (b);
\end{tikzpicture}
\end{document}
3

You can add two nodes to the same path.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {};
\node (b) at (2,0) {};
\draw (a) to node[above] {x} node[below] {y} (b);
\end{tikzpicture}
\end{document}

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.