Open juliangilbey opened 10 months ago
The reason is that quotes imply auto
anchor, i.e. these are equivalent:
\draw [->] (A) to [bend left, "F"] (B);
\draw [->] (A) to [bend left] node[auto] {F} (B);
By means of auto
the anchor is selected by the following heuristic:
If I fumble some \showthe
in there, I can see
> -0.05804pt.
\tikz@auto@anchor ...owthe \pgf@x \showthe \pgf@y
\ifdim \pgf@x >0.05pt\ifdi...
l.42 ...[->] (A) to [bend left] node[auto] {F} (B)
;
?
So for some reason \pgf@y=-0.05804pt
and therefore anchor=south west
instead of anchor=south
is selected. My guess is rounding errors.
Oh wow, thanks so much @hmenke! I don't think I'd have found that in a long long time :) I don't understand what \pgf@x
and \pgf@y
are in this context (and tracing back through the code still leaves me confused), but what is clear is that this code is designed with discontinuities (and it probably can't do any better than that with the current system design), and I just happen to have stumbled upon it. So it's not really a bug, but more a "feature".
And for anyone else reading this, the placement can be adjusted manually by writing something like:
\begin{tikzcd}
C\times D
\ar[r, bend left, "F" above]
\ar[r, bend right, "G"']
& \mathsf{Set}
\end{tikzcd}
tikz-cd, default positioning
which sets the anchor for the F
label to be south
rather than the computed south west
.
Brief outline of the bug
Using pgf version 3.1.10 with an up-to-date MacTeX distribution, an arrow with
bend left
places the label by default somewhat to the right of centre when the left node is large; thebend right
arrow does this when in addition the right node is small. With more investigation, I discovered that there is a discontinuity in label placement between pos=0.48 and pos=0.50, though the exact place varies depending on context. The label placement is also strange when the left hand node is large and the right node is small. I first observed this with tikz-cd, but then tried repeating this with plain TikZ and observed the same behaviour.Minimal working example (MWE)
Here are a sequence of test diagrams illustrating the weird behaviour.
Removing the
12pt
class option fixes some of the diagrams, but not all; presumably tweaking them will resurface this bug.Here are the PDF output and the TeX log file: tikztest.pdf tikztest.log.txt