I'm using marginpar to put graphs and tables in the margins of my document. Sometimes, I end up starting a long note toward the bottom of the page, and it runs off the bottom. To solve this, I can add some negative vspace before the marginpar. But then if an edit moves the marginpar to the top of the next page, it will start too high. Consequently, when I get to the end of editing my document, I need to go back through and check every page to make sure nothing is too far out of place.
What I'd like to do is add a test to see if the marginpar starts too high or ends too low. If it does, I'll put a warning message in the log file. Then I'll be able to search through the log file to see if any marginpars are out of place, and manually fix their location. How can I test if the top or bottom of a box is too high or low? Here's a MWE:
\documentclass{article} \usepackage[textheight=8in,textwidth=4in]{geometry} \usepackage{lipsum} %\usepackage{ifthen} \newcommand{\mnote}[2][0ex]{% \marginpar{\vspace{#1}% \begin{minipage}[c]{\marginparwidth} % \ifthenelse{currentlocation.y < texttop}{\typeout{marginpar too high on page \thepage}}{} #2 % \ifthenelse{currentlocation.y > textbottom}{\typeout{marginpar too low on page \thepage}}{} \end{minipage}% }} \begin{document} \lipsum[1-4] A paragraph at the bottom of the page \mnote{\lipsum[5]} with a long note that goes too low on the page. \lipsum[6] A paragraph at the top of the page \mnote[-3in]{\lipsum[7]} where the note has been moved too high up. \end{document}