14

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.

0

2 Answers 2

15

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}

or with an up-to-date TeX distribution (2018) one needs only

\listfiles
\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage{marginnote}
\usepackage[ngerman]{babel}
\begin{document}
    foo\marginnote{Mülltonnenentsorgungsprogramm}
\end{document}


*File List*
 scrbook.cls    2018/03/30 v3.25 KOMA-Script document class (book)
scrkbase.sty    2018/03/30 v3.25 KOMA-Script package (KOMA-Script-dependent bas
ics and keyval usage)
 scrbase.sty    2018/03/30 v3.25 KOMA-Script package (KOMA-Script-independent b
asics and keyval usage)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
scrlfile.sty    2018/03/30 v3.25 KOMA-Script package (loading files)
tocbasic.sty    2018/03/30 v3.25 KOMA-Script package (handling toc-files)
scrsize11pt.clo    2018/03/30 v3.25 KOMA-Script font size class option (11pt)
typearea.sty    2018/03/30 v3.25 KOMA-Script package (type area)
 fontenc.sty
   t1enc.def    2017/04/05 v2.0i Standard LaTeX file
marginnote.sty    2018/08/09 v1.4b non floating margin notes for LaTeX
   babel.sty    2018/09/02 3.23 The Babel package
 ngerman.ldf    2018/03/29 v2.10 German support for babel (post-1996 orthography)
 ***********
3
  • Leo Liu, Herbert, thanks a lot! ragged2e works perfect!
    – kotsport
    Feb 11, 2011 at 8:29
  • Hm, this does not seem to work if justified text is used as proposed by the manual: \renewcommand*{\raggedleftmarginnote}{} \renewcommand*{\raggedrightmarginnote}{\Centering}
    – math
    Mar 3, 2016 at 10:50
  • Works for me, too!
    – user2478
    Mar 3, 2016 at 12:15
11

This would help:

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

See manuals of marginnote and ragged2e for more information.

You must log in to answer this question.

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