[Tex/LaTex] Memoir footnotes in margin with ragged2e

double-sidedhorizontal alignmentmarginparmemoirragged2e

I would like to set up memoir so that when I use \footnote{foo}, foo is displayed in the margin with the proper label and preferably break over pages.

There is an option \footnotesinmargin which gives almost exactly what I need, only justified. I want it to use ragged2e and change alignment based on even/odd page so that the margin note is always flushed towards the main text area and allows hyphenation on the side of the edge.

\documentclass[12pt, draft]{memoir}
\footnotesinmargin
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{Minion Pro}
\usepackage{kantlipsum}

\begin{document}
\kant[1]\footnote{\kant[1]}
\kant[2]\footnote{\kant[2]}
\kant[3-5]
\end{document}

Possible partial work-around

I have remembered a nice thesis based upon the Classic thesis template and found the source which indeed contains a possible solution:

\usepackage{marginnote}
\usepackage{ragged2e}
\newcommand{\sidemark}[1]{#1.{\:}}

\newcommand{\marginelement}[2][0]{%
  \marginnote{%
    \strictpagechecktrue
    \checkoddpage
    \ifoddpage%
      \RaggedRight\footnotesize%
    \else%
      \RaggedLeft\footnotesize%
    \fi%
    #2%
  }[#1\onelineskip]%
}%

\newcommand{\sidenote}[2][0]{%
  \footnotemark%
  \ignorespaces%
  \marginelement[#1]{%
    \sidemark{\thefootnote}%
    \ignorespaces#2%
  }%
  \unskip%
}%

Nevertheless, I would still prefer a memoir-specific solution with the re-definition of footnotes when used with the option \footnotesinmargin mainly for the sake of portability. This work-around also does not work with hyperref (there is no hypertext connection) and does not break over pages automatically.

Best Answer

You want to be manipulating the \foottextfont.

Something along these lines should do the trick:

\documentclass[12pt, draft]{memoir}
\usepackage{ragged2e}
\footnotesinmargin
\renewcommand{\foottextfont}{%
  \strictpagechecktrue
  \checkoddpage
  \ifoddpage
    \scriptsize\RaggedRight
  \else
    \scriptsize\RaggedLeft
  \fi
 }%
\usepackage{marginfix}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{Minion Pro}
\usepackage{kantlipsum}

\begin{document}
\kant[1]\footnote{\kant[1]}
\kant[2]\footnote{\kant[2]}
\kant[3-5]
\end{document}

Note though that with such heavy margin material, the chances of you being able to have the notes placed correctly is slim. I ran into a similar problem with my thesis and wound up increasing the margin space so that I wouldn't have a problem like the one in this example (where footnote #2 winds up on the wrong page).

Related Question