loopspace / spath3

TikZ/PGF package for manipulating soft paths, includes the knots and calligraphy TikZ libraries.
16 stars 2 forks source link

Bridging code introduces spurious space at document start #18

Open ghost opened 2 years ago

ghost commented 2 years ago

Consider the preamble suggested by the manual of v2.4, page 20:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,spath3}
\tikzset{
  bridging path/.initial=arc,
  bridging span/.initial=8pt,
  bridging gap/.initial=4pt,
  bridge/.style 2 args={
    spath/split at intersections with={#1}{#2},
    spath/insert gaps after components={#1}{\pgfkeysvalueof{/tikz/bridging span}},
    spath/join components upright with={#1}{\pgfkeysvalueof{/tikz/bridging path}},
    spath/split at intersections with={#2}{#1},
    spath/insert gaps after components={#2}{\pgfkeysvalueof{/tikz/bridging gap}},
  }
}
% \AtBeginDocument{
%   \tikz[overlay] \path[spath/save=arc] (0,0) arc[radius=1cm, start angle=180, delta angle=-180];
% }
\begin{document}
First line
\end{document}

When uncommenting the three lines \AtBeginDocument{…}, we get spurious space at the start of the document. (This may seem small, but in a larger example involving svmono and tons of other packages – which I unfortunately cannot cite – this issue magnifies such that I even get one spurious page at the start of the document.) This is a bug and should not happen. Here is the screenshot of diffpdf (the compilation result for the commented version is on the left, for the uncommented version on the right): diffpdf_screenshot I would be happy if this issue finds attention. Thanks in advance.

kpym commented 2 years ago

IMO, the problem comes from a space(s) introduced by the new line inside \AtBeginDocument. For me it is ok when I add comments at the end of the lines (which is a good practice) :

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,spath3}
\tikzset{
  bridging path/.initial=arc,
  bridging span/.initial=8pt,
  bridging gap/.initial=4pt,
  bridge/.style 2 args={
    spath/split at intersections with={#1}{#2},
    spath/insert gaps after components={#1}{\pgfkeysvalueof{/tikz/bridging span}},
    spath/join components upright with={#1}{\pgfkeysvalueof{/tikz/bridging path}},
    spath/split at intersections with={#2}{#1},
    spath/insert gaps after components={#2}{\pgfkeysvalueof{/tikz/bridging gap}},
  }
}
\AtBeginDocument{%
  \tikz[overlay] \path[spath/save=arc] (0,0) arc[radius=1cm, start angle=180, delta angle=-180];%
}
\begin{document}
First line
\end{document}
loopspace commented 2 years ago

This is addressed at https://tex.stackexchange.com/q/605800/86 and two solutions are presented there. I'll update the documentation to use those solutions rather than the current one.

ghost commented 2 years ago

@kpym Thanks! Your solution (introducing %) works indeed for the minimal example at hand. @loopspace Thanks! Please update the documentation the way you think it should be correct.

ghost commented 2 years ago

@loopspace Any progress on the documentation (perhaps, with a bit of testing) so far?

loopspace commented 2 years ago

Must admit that this slipped my mind. Thanks for the nudge.

loopspace commented 2 years ago

I've added a comment about this in the documentation, fix is https://github.com/loopspace/spath3/commit/8fcb4cb0a83b8a6c4930a6a7c0b2c4f08301a207, with a link to the TeX-SX question.