1

I'm a copy editor. For editing reasons I find usefull to spot certain commands used by authors (or by myself in the editing process) directly in the .pdf (or .dvi) file (I know that I can highlight them in my text editor etc., but I have my reasons to do it in this way).

For example, sometimes I need to spot pagebreak commands like \pagebreak, \newpage, \clearpage etc. These commands do not produce a "visible" output in the .pdf (or .dvi) file.

I do something like:

latex "\AtBeginDocument{\let\Oldpagebreak\pagebreak \
\renewcommand{\pagebreak}{\marginpar{\colorbox{red}{pagebreak}}\Oldpagebreak}} \input{file.tex}"

doing so I can pass the string:

\let\Oldpagebreak\pagebreak
\renewcommand{\pagebreak}{\marginpar{\colorbox{red}{pagebreak}}\Oldpagebreak}

to the LaTeX engine without changing the source file.

This is what I get in the .pdf (or .dvi) file:

enter image description here

My problem is that \marginpar has some issues used in this way.

  1. I have warnings like:

    LaTeX Warning: Marginpar on page 23 moved.
    
  2. If the command is used in a floating environment I got the error:

    ! LaTeX Error: Not in outer par mode.
    

My question is how can I avoid these warnings/errors?

Note. I'm opend to other ideas. The most important thing is that the general layout of the document (except for the commands revelation) must remain unchanged.

Edit after the campa and daleif comments.

I tried with the marginnote package. It solved the warnings/error issues.

This is a MWE (for convenience I put the commands in the premble):

\documentclass[11pt]{article}
\usepackage{amsmath}
\pagestyle{empty}

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{marginnote}

\let\Oldsmallskip\smallskip
\renewcommand{\smallskip}{\marginnote{\colorbox{red}{smallskip}}\Oldsmallskip}

\let\Oldmedskip\medskip
\renewcommand{\medskip}{\marginnote{\colorbox{red}{medskip}}\Oldmedskip}

\let\Oldbigskip\bigskip
\renewcommand{\bigskip}{\marginnote{\colorbox{red}{bigskip}}\Oldbigskip}

\let\Oldpagebreak\pagebreak
\renewcommand{\pagebreak}{\marginnote{\colorbox{red}{pagebreak}}\Oldpagebreak}

\let\Oldnewpage\newpage
\renewcommand{\newpage}{\marginnote{\colorbox{red}{newpage}}\Oldnewpage}

\let\Oldclearpage\clearpage
\renewcommand{\clearpage}{\marginnote{\colorbox{red}{clearpage}}\Oldclearpage}

\begin{document}

\begin{figure}
\centering
  \includegraphics[width=.3\linewidth]{example-image}

\medskip

  \caption{Example image.}
\end{figure}

\section{Section 1}
\blindtext

\medskip
\section{Section 2}
\blindtext

\pagebreak

\section{Section 3}
\blindtext

\end{document}

enter image description here

A diffpdf didn't show any problem:

enter image description here

9
  • I'm not sure that the second problem is a rel problem. Something like \clearpage should never appear in a floating environment anyway. Maybe the package marginnote could help, but it would be really helpful to have some document which actually displays the problems. (BTW: I'm not the downvoter, though I think the question has some margin for improvement.)
    – campa
    Jun 24, 2020 at 14:49
  • I tend to use tikz and global positioning instead. Of course then you need to manually move stuff out of the way but so be it. If the original is really bad I'll include it as the left hand side of a landscape A3 and write some very long notes.
    – daleif
    Jun 24, 2020 at 14:50
  • try package marginnote with the macro of the same name. It uses non floating margin pars.
    – user187802
    Jun 24, 2020 at 14:52
  • As campa mentions, I also have good experiences with marginnote, for me through the fixme package. Again this does not move if there are several notes in the same place, but it is actually easy to add an extra option to \fxnote to manually move a note up and down.
    – daleif
    Jun 24, 2020 at 14:52
  • Thus this \fxnote setup is my most used copyediting tool. The tikz and global position I use if I only have access to the PDF.
    – daleif
    Jun 24, 2020 at 14:53

0

You must log in to answer this question.

Browse other questions tagged .