10

I've recently started using tufte-book for typesetting solutions to math problems. I like it very much that you're encouraged to use the margin, which is very nice for giving hints, pointers and references concerning the steps of finding a solution.

Unfortunately, the sidenote and marginnote commands don't work in math environments (not in outer par mode). Most of the time, I'm able to work around it by putting the commands after the environment, using the optional offset with a decimal value via \marginnote[-length]{content}. But this breaks when a math environment is pushed to the end of a page: the notes are then pushed to the next page, no longer appearing on the same page. This also happens if you first put the commands and then the environment.

So, is there any way to enable sidenote and marginnote in math environments? (I thought of using the samepage environment, but this adds a lot of ugly whitespace, as the whole math environment is pushed to the next page without necessity)

\documentclass{tufte-book}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\filler}[1][10]%
{   \foreach \x in {1,...,#1}
    {   test 
    }
}

\begin{document}

\lipsum[1]

\begin{align*}
    &\int\int\int t\ dt^3\\
    =&\int\int \frac{t^2}{2}\ dt^2\\
    =&\int  \frac{t^3}{6}\ dt\\
    =&\frac{t^4}{24}
\end{align*}\marginnote[-3.7cm]{first note}\marginnote[-1.7cm]{second note}

\lipsum[2]
\filler[50]

\begin{align*}
    &\int\int\int t\ dt^3\\
    =&\int\int \frac{t^2}{2}\ dt^2\\
    =&\int  \frac{t^3}{6}\ dt\\
    =&\frac{t^4}{24}
\end{align*}\marginnote[-3.7cm]{first note}\marginnote[-1.7cm]{second note}

\end{document}

enter image description here

As you can see, the second align* is still on the first page, but the marginnotes are pushed to the second page.

1
  • I see three notes: the first "first note", the first "second note" and the second "second note". Where did the second "first note" end up?
    – Gus
    Jun 2, 2021 at 17:51

1 Answer 1

11

The AMS environments conveniently give you a hook to place text at a known position relative to the margin so I'd do

\documentclass{tufte-book}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\filler}[1][10]%
{   \foreach \x in {1,...,#1}
    {   test 
    }
}

\def\mathnote#1{%
  \tag*{\rlap{\hspace\marginparsep\smash{\parbox[t]{\marginparwidth}{%
  \footnotesize#1}}}}
}

\begin{document}

\lipsum[1]

\begin{align*}
    &\int\int\int t\ dt^3\\
    =&\int\int \frac{t^2}{2}\ dt^2\\
    =&\int  \frac{t^3}{6}\ dt\\
    =&\frac{t^4}{24}
\end{align*}\marginnote[-3.7cm]{first note}\marginnote[-1.7cm]{second note}

\lipsum[2]
\filler[50]

\begin{align*}
    &\int\int\int t\ dt^3\mathnote{first note}\\
    =&\int\int \frac{t^2}{2}\ dt^2\\
    =&\int  \frac{t^3}{6}\ dt\\
    =&\frac{t^4}{24}\mathnote{second note}
\end{align*}

\end{document}
7
  • Thank you, that's what I was looking for. Your code was missing a closing } in the mathnote definition, so I took the liberty to add it. Jul 12, 2012 at 14:26
  • 1
    After reading Aleander Perlis' A complement to \smash, \llap, and \rlap, I not only use your solution, but finally do understand it. Thanks again. Sep 28, 2012 at 16:41
  • +1! But just to be sure: This solution only works for the align environment and not for the equation environment? At least it failed in what I tested.
    – user122292
    Jan 21, 2018 at 20:35
  • @flobo equation* works if you fix the definition by adding \kern1sp before the \rlap Jan 21, 2018 at 20:50
  • 1
    @DavidCarlisle: Coincidentally, I was searching the answer to flobo's very question, only 24h after they asked. In any case, it seems that adding the \kern does not break \mathnote in align environments. If that does make sense, maybe it'd be better to have it defined with the \kern in your answer? Would you mind explaining what's happening with it? Cheers!
    – Michaël
    Jan 23, 2018 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .