It seems LaTeX can't tell whether it's on an even or odd page when it's at the beginning of a new page. I'm trying to put text in the margin using a custom sort of method in a book that I'm writing. marginpar and marginnote won't work for various reasons. I found this method here. I don't fully understand the syntax but I can mostly tell what it's doing.
I've printed things to the margins in 3 places using marginpar marginnote and the custom method, mynote: once at the beginning of the document, once at the beginning of a new page of the document, and once at the beginning of a new page of the document that is created by \newpage. The 1st and 3rd instances put each of the text in the correct place, but the second instance puts the mynote in the wrong margin, as though it thinks it's still on the previous page.
I've tried \strictpagecheck, that doesn't do anything. I can't really think of anything else to try.
Can anyone give some insight? To clarify, I want to have the "My Note" on the second page be on the left, as it should be, and as the marginpar and marginnote are.
EDIT: As per @Werner 's recommendation, I have changed it to
\documentclass{book}
\usepackage{marginnote}
\usepackage{tabto}
\usepackage{changepage}
\newcommand\mynote[1]{%
\checkoddpage\ifoddpage
\tabto*{\dimexpr\textwidth+\marginparsep}%
\else
\tabto*{\dimexpr-\marginparsep-\marginparwidth\relax}%
\fi
\smash{\begin{minipage}[t]{\marginparwidth}{#1}\end{minipage}}%
\tabto*{\TabPrevPos}%
}
\begin{document}
\marginnote{Margin Note}
\mynote{My Note}
\marginpar{Margin Par}
\vspace{60em}
\marginnote{Margin Note}
\mynote{My Note}
\marginpar{Margin Par}
\newpage
\marginnote{Margin Note}
\mynote{My Note}
\marginpar{Margin Par}
\end{document}
But it still doesn't seem to get the My Note to the left on the second page for me, no matter how many times I compile. The output is here
If it helps to know the context, I'm using this MyNote thing for my "Asides" in my book on page 232.
\marginpardoes, I think, is to save the marginal note into a box and then use that later in a context when it can be more confident of getting the checks right. But note that marginal notes will still sometimes end up on the wrong side if things get sufficiently complicated. – cfr Nov 10 '16 at 03:22