1

The Problem

When I insert a \todo with one or more lines of text, the text shifts a bit down due to inserted \par.

MWE

This example is only partially minimal in case parts like memoir impact the problem.

\documentclass{memoir}

\usepackage{todonotes}

\copypagestyle{mystyle}{headings} \makeevenhead{mystyle}{\thepage}{}{\rightmark} \makeoddhead{mystyle}{\rightmark}{}{\thepage} \makeevenfoot{mystyle}{}{hello}{} \makeoddfoot{mystyle}{}{hello}{} \pagestyle{mystyle} \makeheadrule{mystyle}{\textwidth}{\normalrulethickness}

\begin{document} \chapter{the chapter} {% \thispagestyle{mystyle} \clearpage \todo{this is my todo\it has several\lines} \section{mysection} blah blah }% \clearpage \pagestyle{plain} {% \thispagestyle{mystyle} \clearpage \section{mysection} blah blah }% \end{document}

The Question

How do I prevent this such that the spacing is always consistent (like section 1.2 rather than section 1.1 in the MWE)?

WesH
  • 427
  • 2
    \todo is equivalen to \hbox{}. It takes up no horizontal space, but by itself will create a line of text. \vspace{-\baselineskip} will help. I would put the \todo inside the section name (but not the optional short name). – John Kormylo Dec 23 '22 at 23:46
  • Are you sure you're using the right tool? The \todo items will not be part of the final version of the document, so why bother about pagination and spaces when the document is not yet in final form? To the contrary, if the parts you're inserting with \todo are probably just margin paragraphs (maybe decorated). – egreg Dec 24 '22 at 13:42
  • @egreg - I'm using \todo outside of its intended purpose, but I am always open to learning about a new tool. I originally tried using marginnotes and \marginpar, but I had trouble getting the decorations I wanted (not pictured in the MWE for this question). I switched to todonotes since it had more and more user-friendly options built in. I remember having similar problems with paragraph spacing in the other two options I tried. – WesH Dec 24 '22 at 19:16
  • @JohnKormylo - This is a good suggestion, but it does not behave well in practice. An integer of \baselineskip does not shift the section heading correctly, possibly due to the issue here. Using \vspace{-30pt} for the MWE gets me close, but this does not have the automagic quality for me doing weird things in the \todo not mentioned in the MWE. See comment above about me doing silly things. – WesH Dec 24 '22 at 19:33
  • Ah yes, the top of the page absorbs the spacing above \section. You can achive the same affect using \csname @minipagetrue\endcsname but it is still slightly off. But as @egreg noted, why bother when it is going to be removed eventually? – John Kormylo Dec 24 '22 at 21:59

1 Answers1

1

This is how I would do it:

\documentclass{memoir}

\usepackage{todonotes} \usepackage{showframe}

\copypagestyle{mystyle}{headings} \makeevenhead{mystyle}{\thepage}{}{\rightmark} \makeoddhead{mystyle}{\rightmark}{}{\thepage} \makeevenfoot{mystyle}{}{hello}{} \makeoddfoot{mystyle}{}{hello}{} \pagestyle{mystyle} \makeheadrule{mystyle}{\textwidth}{\normalrulethickness}

\begin{document} \chapter{the chapter} {% \thispagestyle{mystyle} \clearpage \section[mysection]{\todo{this is my todo\it has several\lines}mysection} blah blah }% \clearpage \pagestyle{plain} {% \thispagestyle{mystyle} \clearpage \section{mysection} blah blah }% \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120