0

How to suppress the unexpected space between the characters ==> and <==, due to the putmarginpar, please? (I work with a strengthen text, because I have few space in my document)

\documentclass[a5paper, para]{book}
\usepackage[left=1cm, right=1cm, top=0.5cm, bottom=0.3cm, includeheadfoot] {geometry}
\usepackage[french]{babel}
\usepackage[x11names]{xcolor}
\usepackage{multicol}
\usepackage{zref-savepos}
\usepackage{ifthen, pgffor}
\usepackage{setspace}

\setlength{\columnsep}{3mm}\setlength{\columnseprule}{0.1mm} \setstretch{0.80}\fontdimen2\font=0.25em\fontdimen3\font=0.25em

\makeatletter \def\putmarginpar#1#2{ \zsavepos{#1} \ifnum6139194>\number\zposx{#1}% \hbox to 0pt{\hskip\dimexpr-\zposx{#1}sp +1.0cm \relax#2} \else \hbox to 0pt{\hskip\dimexpr-\zposx{#1}sp +20.5cm \relax#2} \fi } \makeatother

\newcommand{\bv}{This is a sample of a text.} \newcommand{\bvn}[2]{\foreach \n in {#1,...,#2} { \bv}} \newcommand{\txt}[2]{\foreach \n in {#1,...,#2} { \bvn{1}{5}\textcolor{red}{==>}\putmarginpar{40:1:1}{1}\textcolor{red}{<==}\bvn{1}{5}\ }}

\begin{document} \begin{multicols}{2}

\txt{1}{9}

\end{multicols} \end{document}

  • Welcome to tex.sx. This is just a shot in the dark (not tested). In the definition of \putmarginpar there are an awful lot of "spurious spaces". Remember that an end-of-line is treated as a space. So if you "protect" those positions -- following an opening or closing brace, for example -- with a %, it won't be possible for a space to be output there. – barbara beeton Feb 24 '23 at 16:22
  • Ah OK. With this, it is better, but there is still unexpected spaces. Thanks for your rapid response – Dominique Audéoud Feb 24 '23 at 21:08
  • \def\putmarginnote#1{\checkoddpage\ifoddpage{\begingroup\docolaction{\reversemarginpar}{}{}\oldmarginnote{#1}\endgroup}\else{\begingroup\docolaction{}{}{\reversemarginpar}\oldmarginnote{#1}\endgroup}\fi} – Dominique Audéoud Feb 24 '23 at 21:08
  • You might include that code as an addendum to the question, to give a better starting point for someone able to experiment. – barbara beeton Feb 24 '23 at 22:02
  • I thank you for your help. Finally, the "unexpected" spaces are very "descreet". I have now a beautiful text! – Dominique Audéoud Feb 25 '23 at 08:25
  • Proposed duplicate: Why the end-of-line % in macro definitions? (It, in turn, is noted as a duplicate to a question that has answers with more basic explanations.) – barbara beeton Feb 25 '23 at 15:28
  • Thanks for your useful recall. I am new with Latex, have read the documentation, but forgot this point ! – Dominique Audéoud Mar 15 '23 at 08:51

0 Answers0