If you want to change the lengths of arrows in a tikzcd diagram, there are lots of options:
- Append "shorten => 10pt" or "shorten >= 15pt" to the arrow description.
- Change the row/column separation using [{column sep = 15pt, row sep = 20pt}] at the start of the tikzcd.
- Change individual column/row separations using [-15pt] or [5pt] before the appropriate & or // .
I am not asking about any of these.
If I want the absolute length of all (or one) of my arrows to be say 20pt, how can I do that?
That is, so all (or one in particular) of my arrows is 20pt long. Note that none of the above options do this.
Best Answer
Here is a possibility. Define a new arrow type called
myarrow
, which is a white arrow decorated with a special arrowhead. The arrowhead is aButt Cap
of a given length followed by a standard arrowhead (shifted to keep it centered). The length is controlled globally by\myarrowlength
. You can then usemyarrow
for a single arrow as in the first example using\arrow[r, myarrow]
, or for all arrows as in the second example using\begin{tikzcd}[arrows=myarrow]
Update:
To add labels to the arrows, the white arrow must get a label. This is now included in the definition, along with a default empty label. For example,
myarrow="h"'
will place the labelh
on the "right" side. Use{}
for more complicated labels, e.g.,myarrow={"h"', text=red}
.