Document Classesmemoir class: get ragged marginalia?

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
magister
Posts: 17
Joined: Sun Aug 02, 2009 4:42 am

memoir class: get ragged marginalia?

Post by magister »

I'm using memoir to produce a book with lots of margin paragraphs and side captions. I'd prefer that these elements be ragged on the outside and flush on the inside (e.g., on a recto page they would be flush left and ragged right). I thought that was the default, but I'm getting fully justified paragraphs. A search of the memoir manual has not enlightened me. I'd appreciate any help.

David

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

memoir class: get ragged marginalia?

Post by gmedina »

Hi David,

in the following code I defined the \ragmarpar command that will typeset raggedright margin notes on an odd page and raggedleft margin notes on an even page. I used the \RaggedRight and \RaggedLeft commands from the ragged2e package to allow hyphenation inside the margin notes.

Code: Select all

\documentclass{memoir}
\usepackage{ifthen}
\usepackage{ragged2e}
\usepackage{lipsum}% just to automatically generate some text

\newcounter{pl}
\newcommand\ragmarpar[1]{%
   \stepcounter{pl}\label{pl-\thepl}%
   \ifthenelse{\isodd{\pageref{pl-\thepl}}}%
    {\marginpar{\RaggedRight #1}}
    {\marginpar{\RaggedLeft #1}}
}

\begin{document}

\lipsum[1]
\ragmarpar{\lipsum[1]}
\lipsum[1-4]
\ragmarpar{\lipsum[1]}
\lipsum[1-4]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
magister
Posts: 17
Joined: Sun Aug 02, 2009 4:42 am

Re: memoir class: get ragged marginalia?

Post by magister »

Thank you! This works perfectly in my document. I'm not much of a programmer, but I'll see if I can use your model to get side captions ragged also. Thanks too for the reference to ragged2e package; I wasn't familiar with it.

David
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

memoir class: get ragged marginalia?

Post by gmedina »

You are welcome.
magister wrote:...I'll see if I can use your model to get side captions ragged also...
The caption package implements this option. Please refer to the package documentation (Section 2.2 "Justification", pages 8 and 9).

Additionally, the memoir class provides the \captionstyle command that allows you to obtain ragged captions; (see the manual, page 188).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
magister
Posts: 17
Joined: Sun Aug 02, 2009 4:42 am

memoir class: get ragged marginalia?

Post by magister »

Additionally, the memoir class provides the \captionstyle command
Yes, that's one thing I really like about memoir--it does many things that eliminate the need for separate packages (with possible conflicts). I used the caption package in the past but rarely need it now that I use memoir for projects of any length. My notion that memoir could do ragged right margin pars was probably misremembered info about ragged right captions. Back to the manual!

David
Post Reply