0

So I've used the wonderful tool "tikz-cd editor": https://tikzcd.yichuanshen.de/ I am also using Overleaf for what it's worth.

\arrow[rr, "\digamma"]

versus

\arrow[r, "\digamma"]

I'm guessing what this does is "right | right" instructions, rather than "right" a single time as we might expect from the latter.

My document appears as follows: This is what one would expect from the markup/code provided, there is nothing being modified, and no issues occuring. It features a heading "tikz playground", with letters alternating between upper case and lower case. There is also my name, Brayton, below a mathematical expression. The expression is underneath the title plaintext but still included in the title command. The expression is <code>$$\mathfrak{c}_{\mathbf{u}} \in \mathbb{N}(t)$$</code>

If so, given:

\begin{tikzcd} \rho_i \arrow[rr, "\mathcal{F}"] &  & \mu_i \arrow[rr,
 "\digamma"] &  & S_i \arrow[rr, "\mathscr{F}"] &  & \mathfrak{R}
 \end{tikzcd}



 $$\\ \\ \\ \\ \\ \mathfrak{A}$$

Also, how does [swap] command work for "swapping" the side of the arrow which text appears on (left hand side of the direction of the arrow is the default position for arrow labels to be placed). I would like to have \mathfrak{A} be directly below the arrow labelled by \mathscr{F}.

I find myself facing a nasty mess if I change any of these "rr" to "r". Is this because there are "& &" also used, and the "rr" requires "&&"? Does "rr" do anything special here, or does it default to behaving like "r" in the absence of "r" paired with "&"? (e.g. unless an arrow of length 1 is defined in the same diagram, arrows of length 2 will be scaled down to length 1).

Just another example of the code outputted by the tool:

\begin{tikzcd} A \arrow[dd, tail] \arrow[rddd, bend left=49] \arrow[r,
 dashed] & B \arrow[rr] \arrow[rrd, bend left] \arrow[rddd, bend
 left=49] &                                   & A:B \arrow[d] \\
                                                                 &                                                                &                                   & B^A           \\ A' \arrow[rd]
\arrow[rrru, bend left]                           &                   
 &                                   &               \\
                                                                 & {P[A||B]} \arrow[r, dashed]                                    &
 {Q[A|A']} \arrow[ruu, bend right] &               \end{tikzcd}

Is the general gist that the "&" tells TikZ-cd where to put a blank area for the arrows to zoom through, and any mismatch will cause chaos? From my perspective, the layout of the above code doesn't really resemble a matrix/2d array very clearly at all. Does anyone have guidance for interpreting and deciphering the markup for these diagrams/diagram instructions, or is this obfuscation largely dependant upon the particular tool (and how machines may write it versus how humans would tend to)?

There are plenty of other TikZ GUI tools, and I will eventually migrate (and learn to draw manually), though for now I'm in a bit of a pinch.


Also, I've noticed there's a fair few questions of the format "What exactly does [SOMETHING] and [OTHERTHING] do?". I could ask this in a metaTeXSX post but I'm guessing this is a fine format for asking?

Would it be better if I split this into two questions, one about "rr" vs "r", and one about [swap]: labeling under and above the arrows of length "rr"?

2
  • 2
    You have a grid the & separates cells on each row of the grid. \arrow want to draw an arrow from the cell it is placed in to another cell. The most convenient way to specify this is relative to where we are now. So rr means make an arrow from the current cell to the cell two steps to the right. dl means arrow to the cell that is one cell down and one cell to the left.
    – daleif
    Commented Dec 16, 2019 at 12:27
  • tikz-cd uses a TikZ matrix of nodes and the & have the same role as in any other matrix or table: it separates cells, as @daleif says. swap just swaps the position of the label, if it was original on one side of the arrow, swap will move it to the other.
    – user194703
    Commented Dec 16, 2019 at 15:59

1 Answer 1

2

TikZ-CD uses a TikZ \matrix under the hood that's setup in a way so that every cell's content is to be understood to be a single node's math content.

This makes it that one can use a very similar syntax to tabulars or arrays to create a diagram. As with those, & separates the columns while \\ separates the rows.

While with the tabular or array environments, the & is its own catcode and denotes an actual new column, TikZ has to cheat a bit and make & active (similar to ~, the unbreakable space). If you need to use a TikZ matrix or the TikZ-CD environment as an argument to a macro or some special environments, you will need the option ampersand replacement.
Usually, that means using ampersand replacement = \& on the tikzcd environment and using \& instead of &.

Though, for all intents and purposes & just means: a new column.

(In contrast to plainTeX's $ and $$, there is no different between && and & &.)


I'm guessing what this does is "right | right" instructions, rather than "right" a single time as we might expect from the latter.

Correct, TikZ-CD provides a simply shortcut syntax to specify the target of an arrow coming from the cell where \arrow shows up. \arrow[rr] just instructs TikZ-CD to draw an arrow from here to the cell two columns further to the right.

If you specify a target that does not exist, PGF/TikZ(-CD) will complain about an unknown node name.

It looks like you have used the tool in a way that will only fill every second column, leaving one cell empty. This isn't breaking anything, it just adds double the column separation between your content.

These are equivalent otherwise, but notice the use of only r instead of rr when I remove one & each:

\begin{tikzcd}
   \rho_i
     \arrow[rr, "\mathcal{F}"]
 &
 & \mu_i
     \arrow[rr, "\digamma"]
 &
 & S_i
     \arrow[rr, "\mathscr{F}", "\mathfrak{A}"']
 &
 & \mathfrak{R}
\end{tikzcd}

\begin{tikzcd}
   \rho_i
     \arrow[r, "\mathcal{F}"]
 & \mu_i
     \arrow[r, "\digamma"]
 & S_i
     \arrow[r, "\mathscr{F}", "\mathfrak{A}"']
 & \mathfrak{R}
\end{tikzcd}

enter image description here


Also, how does swap command work for "swapping" the side of the arrow which text appears on (left hand side of the direction of the arrow is the default position for arrow labels to be placed). I would like to have \mathfrak{A} be directly below the arrow labelled by \mathscr{F}.

Let me quote myself here for a moment:

The labels are placed intelligently, always to the left of the arrow. That's the default direction of the TikZ auto option that's installed by TikZ-CD.

It only knows left and right, meaning the nodes along a path are placed either to the left or the right of the path. (The swap (') key just checks which one's active and installs the other one.)

So swap and its shortcut ' just literally swaps the side the label will appear.

As you have noticed, using " in the options for an \arrow will add that text between " as a label along the path (by default using the auto = left option and the midway point along it).

You can use it twice on the same arrow, adding another label, and with

"\mathfrak{A}"'
% or
"\mathfrak{A}" swap

you can, well, swap the side. Check the previous code example, I've already used it.


All the other stuff that's in your generated code is either a math macro provided by some package or an existing key from TikZ or TikZ-CD:

  • \mathfrak and \digamma from amssymb
  • \mathscr from mathrsfs
  • bend left from TikZ
  • tail and dashed from TikZ-CD

For everything else I refer you to the TikZ-CD manual, though the TikZ manual will be needed eventually for some creative paths.


In the code below, I've reorganized your bigger diagram so that it needs only straight arrows (which weren't really necessary to begin with) and takes up less space.

I'd avoid bended arrows unless you need to get around something. Maybe a variation on the slanted orthogonal paths from another answer of mine could be of use.

Code

\documentclass[varwidth]{standalone}
\usepackage{
  amssymb, % for \mathfrak, \digamma
  mathrsfs % for \mathscr
}
\usepackage{tikz-cd}
\tikzcdset{% https://tex.stackexchange.com/a/663065/16595
  -|/.style={to path={-|(\tikztotarget)\tikztonodes}},
  -| ysl/.style ={-|, yslant=#1}}
\begin{document}
\begin{tikzcd}
   \rho_i
     \arrow[rr, "\mathcal{F}"]
 &
 & \mu_i
     \arrow[rr, "\digamma"]
 &
 & S_i
     \arrow[rr, "\mathscr{F}", "\mathfrak{A}"']
 &
 & \mathfrak{R}
\end{tikzcd}

\begin{tikzcd}
   \rho_i
     \arrow[r, "\mathcal{F}"]
 & \mu_i
     \arrow[r, "\digamma"]
 & S_i
     \arrow[r, "\mathscr{F}", "\mathfrak{A}"']
 & \mathfrak{R}
\end{tikzcd}

\begin{tikzcd}
   A \arrow[d, tail]
     \arrow[rdd]
     \arrow[r, dashed]
 & B \arrow[r]
     \arrow[rd]
     \arrow[rdd]
 & A:B
     \arrow[d]
\\
   A'
     \arrow[rd]
     \arrow[rr]
 & & B^A \\
 & P[A||B] \arrow[r, dashed]
 & Q[A|A'] \arrow[u]
\end{tikzcd}

\begin{tikzcd}
   A \arrow[d, tail]
     \arrow[rdd, -| ysl=-.5]
     \arrow[r, dashed]
 & B \arrow[r]
     \arrow[rd]
     \arrow[rdd]
 & A:B
     \arrow[d]
\\
   A'
     \arrow[rd]
     \arrow[rr, crossing over]
 & & B^A \\
 & P[A||B] \arrow[r, dashed]
 & Q[A|A'] \arrow[u]
\end{tikzcd}
\end{document}

Output

enter image description here

You must log in to answer this question.

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