2

I want to create a little diagram that looks like:

enter image description here

with $\implies$ (double-lined arrow) for the arrows. And I'd like to be able to write things on the arrows if possible.

How can I do this? I've never used latex to create a diagram before!

2

A short code with tikz-cd:

\documentclass[border=3pt]{standalone}
\usepackage{tikz-cd, amsmath}

\begin{document}\begin{tikzcd}
(a) \rar[Rightarrow, bend right, "f"] & \lar[Rightarrow, bend right, swap, " g"] (b) & \lar[Rightarrow, swap, " h "](c)
\end{tikzcd}

\end{document} 

enter image description here

2

What you are looking for is the TikZ package (https://www.ctan.org/pkg/pgf). It has become the de-facto standard drawing tool within LaTeX. The picture you gave could be written as

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\node at (0, 0) (a) {(a)};
\node at (2, 0) (b) {(b)};
\node at (4, 0) (c) {(c)};

\draw [double, ->, bend right, auto, swap] (a) to node {label 1} (b);
\draw [double, ->, bend right, auto, swap] (b) to node {label 2} (a);
\draw [double, ->, auto] (c) to node {label 3} (b);

\end{tikzpicture}
\end{document}

and would render as enter image description here

Now, what is happening here? You might consider the tikzpicture the canvas on which to draw. The three \node commands create points on the canvas at the given coordinates (0, 0), (2, 0), and (4, 0), respectively (the first number being the horizontal coordinate from left to right and the second one the vertical, from bottom to top). For later reference, these are called a, b, and c, respectively and drawn as such, with parentheses.

The \draw commands are responsible for the arrows. We’ll ignore the options for a moment and pretend the command was \draw (c) to node {label 3} (b). This draws a line from the point we call c to the point b. In order to label the line, we create another node ad hoc using node {label 3}, where the thing in braces is the text to appear next to the line.

The options to the \draw command do the following:

  • double draws two lines instead of one to make them appear like the “implies” arrow, as you requested.
  • -> specifies the arrow’s tips. That is, no tip at the beginning (straight line -, and an arrow tip at the end, >.
  • bend right is for the curvature. bend left is also possible. Note that both arrows are bent right.
  • auto positions the line’s label cleverly. Try compiling the example without the option: The label will be written on the line instead of next to it.
  • swap controls whether the label should appear to the left or to the right of the line. If neither line had the swap option, the labels would be set between the lines, with little spacing between them. Try it out!

TikZ is a intimidatingly powerful package. When learning to use it, you should definitely follow the package author’s invitation to follow the tutorials at the beginning.

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.