4

If I typeset the following, (obviously) the top of the marginpar aligns with the last line of the paragraph, which looks ugly.

\documentclass{article}
\begin{document}
Some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text.\marginpar{Lorem ipsum dolor sit amet, consectetur adipiscing elit.}
\end{document}

Is there a way to align the bottom of a marginpar with the last line of the paragraph?

2 Answers 2

4

Yes. Note that it pokes above the top of the text area.

\documentclass{article}
\begin{document}
Some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text some text.
\marginpar{\raisebox{\height}[0pt]{\parbox{\marginparwidth}{\sloppy Lorem ipsum dolor sit amet, consectetur adipiscing elit.}}}
\end{document}
1

Building up on the previous answer of John Kormylo, I try to address the issue of the box being raised too high if the previous paragraph extends only little into the next page.

\documentclass{article}
\usepackage{kantlipsum}
\usepackage{etoolbox}

\newcommand{\marginparbottom}[1]{
  \marginpar{%
    \raisebox{
      \ifdimcomp{\height}{>}{\pagetotal}{%
          \dimexpr\pagetotal-5.95pt\relax
        }{%
          \dimexpr\height\relax%
        }%
      }{%
        \parbox{\marginparwidth}{\sloppy #1}%
      }
    }
  }

\begin{document}
\section{One}
\kant[1-3]
\section{Two}
\kant[1]
\marginparbottom{ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.}
\end{document}

This somewhat works, but for some reason the manual calculation to account for baseline offset in the if-true-clause does not have any effect. It would be nice, if the first horizontal box in the margin paragraph did not rose above the first horizontal box in the main body.

You must log in to answer this question.

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