I am using inline tikz calls to create annotations in my documents.
I am using the (below defined) \Curve macro to annotate graph plots (e.g. created with pgfplots) and \Curvee macro for more general drawings that could be bent, hence the use of to path instead of -- path. I manage to align the contents of the \tikz call using the baseline option and some current bounding box properties.
However, when using bend ... or in=...,out=... options to the to path, empty space is left inside the bounding box.
When -stealth arrows are used there are also some discrepancies in the bounding box. Note that a -Stealth arrow updates the bounding box very well.
In this post it is said that the arrrows for the arrows.meta library should update the bounding box (while previous arrows could not).
So I have two questions actually :
- Why do the
stealtharrows no update the bounding box correctly ? (I thought they were just-Stealtharrows with some default settings, but maybe not) - Why is there an empty space in the bounding box of
to pathwihtin=...,out=...options ? (probably because of some construction nodes but if someone can explain...)
\documentclass{article}
\usepackage{tikz}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{times}
\usepackage{mathptmx}
\usetikzlibrary{arrows.meta,calc}
\usepackage{xparse}
\DeclareDocumentCommand\Curve{ m O{} }{%
(%
\tikz[baseline=(ref.base)] {%
\draw[#1] plot coordinates {(0,0)} -- plot[#2] coordinates {(2mm,0)} -- plot coordinates {(4mm,0)};%
\draw[] (current bounding box.south west) rectangle (current bounding box.north east);
\coordinate[yshift=-\the\dimexpr\fontdimen22\textfont2] (ref) at (current bounding box.center);
}%
)%
}
\DeclareDocumentCommand\Curvee{ m O{} }{%
(%
\tikz[baseline=(ref.base)] {%
\draw[#1] (0,0) to[#2] (4mm,0mm);%
\draw[] (current bounding box.south west) rectangle (current bounding box.north east);
\coordinate[yshift=-\the\dimexpr\fontdimen22\textfont2] (ref) at (current bounding box.center);
}%
)%
}
\begin{document}
$1$
\Curve{red,-stealth}
\Curve{red,->}
\Curvee{red,-stealth,bend left}
\Curvee{red,->,bend left}
\Curvee{red,-stealth}[out=-60,in=150]
\Curvee{red,-Stealth}[out=-60,in=150]
\end{document}


\DeclareDocumentCommand, but prefer\NewDocumentCommand, so you'll be warned if you're trying to define an existing command. – egreg Sep 13 '19 at 08:48NewDocumentCommand, in general my personal macros are in french so overriding is not that common ^^. Regarding the controls points, that's what I thought at first, but thebend leftactually definesin=...,out=...settings and does not leave so much space. Any idea regarding thestealtharrows ? – BambOo Sep 13 '19 at 09:11bend leftis idiotic, for sure with a two-sloped curve, the control points will be farther from the center. Sorry about that – BambOo Sep 13 '19 at 11:01