# Automatic hyphenation in margin notes

I build a document with notes (like footnotes) on margins. I found help on LaTeX community and now my preamble looks like that:

\documentclass{book}

\usepackage{marginnote}
\renewcommand*{\marginfont}{\footnotesize}
\newcounter{mynote}
\newcommand{\mynote}[2][0]{
\refstepcounter{mynote}
\mbox{\textsuperscript{\themynote}}
\marginnote{\mbox{\textsuperscript{\themynote}}\hspace{0pt}#2}[#1\baselineskip}
\newcommand{\mybr}{-\\}


Everything works pretty well except automatic hyphenation. I need to divide words manually by using \mybr{}. I prefer ragged notes, but justified could be too, if automatic hyphenation works only like this.

-

TeX doesn't hyphenate the first word in a paragraph. You can write a \hspace{0pt} before it, then TeX takes this as first word or use lualatex it hasn't such restriction.

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{marginnote}
\usepackage[ngerman]{babel}
\usepackage{ragged2e}
\renewcommand*{\raggedleftmarginnote}{\RaggedLeft}
\renewcommand*{\raggedrightmarginnote}{\RaggedRight}
\newcommand\Marginnote[1]{\marginnote{\hspace{0pt}#1}}

\begin{document}
foo\Marginnote{Mülltonnenentsorgungsprogramm}
\end{document}

-
Leo Liu, Herbert, thanks a lot! ragged2e works perfect! – kotsport Feb 11 '11 at 8:29
Works for me, too! – Herbert Mar 3 at 12:15

This would help:

\usepackage{marginnote}
\usepackage{ragged2e}
\renewcommand*{\raggedleftmarginnote}{\RaggedLeft}
\renewcommand*{\raggedrightmarginnote}{\RaggedRight}


See manuals of marginnote and ragged2e for more information.

-