# Horizontal space after tikzpicture[overlay, remember picture]

I'm writing a document using a template that is not mine, in which, after an equation, some arrows are added using TikZ, by defining tikzmarks and using the overlay, remember picture options to the tikzpicture environment.

I've noticed that if one adds text immediately after \end{tikzpicture} then a little bit of white space is added at the beginning of the line. Here you can see a MWE:

\documentclass[letterpaper,11pt,oneside]{article}

\usepackage{lipsum}
\usepackage{amsmath}
\usepackage[showframe]{geometry}
\usepackage{tikz}
\usetikzlibrary{tikzmark, arrows}

\renewcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}

\noindent\lipsum[1][1-3]

\begin{equation*}
\tikzmark{a} A = \tikzmark{b} B + C \tikzmark{c}.
\end{equation*}
\begin{tikzpicture}[overlay,remember picture]
\node (A1) [left of = a, node distance = 4.5em, yshift=0.8em]{\footnotesize lorem};
\node (A2) [left of = a, node distance = 0em, yshift=0.25em]{};
\draw[->, in=180, out=350] (A1.east) to (A2.west);
\node (B1) [left of = b, node distance = 4.5em, yshift=1.9em]{\footnotesize ipsum};
\node (B2) [left of = b, node distance = 0em, yshift=0.8em]{};
\draw[->, in=150, out=350] (B1.east) to (B2.west);
\node (C1) [right of = c, node distance = 4.5em, yshift=1.9em]{\footnotesize dolor};
\node (C2) [right of = c, node distance = -0.5em, yshift=0.8em]{};
\draw[->, in=45, out=210] (C1.west) to (C2.east);
\end{tikzpicture}
\lipsum[1][1-3]

\noindent \lipsum[1][1-3]

\end{document}


This produces the following output (I added the geometry package with option showframe to show the margins). Notice the sentence after the equation:

I tried to apply the solutions given here and here (and the subsequent links cited there), but to no avail.

Any help will be appreciated. Thank you very much in advance!

• If using a recent version of tikzmark then your redefinition is unnecessary: use \tikzmarknode instead. – Andrew Stacey Aug 26 '19 at 19:41

The tikzpicture environment creates a zero size box, resulting in a new paragraph being started. The line ending between \end{tikzpicture} and the text will then show up at the beginning of the paragraph, following the zero size box.
You can get rid of it by placing a % immediately after \end{tikzpicture}.
Another solution is to move the tikzpicture inside the equation, i.e., move \end{equation*} down after \end{tikzpicture}. Then the space is in math mode, where it does no harm. Arguably, that is a more logical placement anyhow, as the arrows belong with the equation and not the following text.