Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

We used the following code fragment

\newcommand{\raggedouter}{%
    \checkoddpage%
        \ifoddpage%
        \RaggedRight%
        \else%
        \RaggedLeft%
        \fi%
}

to provide a \raggedouter command, inspired by the tufte-latex class. Please see the following image to demonstrate the effect in a two-side book.

enter image description here

It is not uncommon and is done by Bringhurst's The Elements of Typographic Style or even in the German Der LaTeX-Begleiter by Mittelbach and Goosens. I would suspect the function in a package such as ragged2e. Does the upper code-fragment cover all possible cases? If there is a good solution, would it be an appropriate feature request for ragged2e?

share|improve this question
1  
Looks very good and yes could it makes a good feature request or patch the package yourself. –  Yiannis Lazarides Oct 20 '11 at 19:30
    
I want to add the following example to emphasize, that it is not limited to \marginpar per se: I use e.g. \DeclareCaptionJustification{raggedouter}{\raggedouter} \captionsetup{width=\marginparwidth, justification=raggedouter, font=footnotesize, skip = 0pt} with the caption package. –  Andy Oct 21 '11 at 5:41
add comment

2 Answers

up vote 6 down vote accepted

The command \marginpar already does the check for odd pages or even pages, so it's simpler to say

\newcommand{\mymarginpar}[1]{%
  \marginpar[\raggedleft#1]{\raggedright#1}}

and to use \mymarginpar to insert marginal notes. Of course you can change \raggedright and \raggedleft with the similar commands provided by ragged2e, if you think they are better for you.

You may want to load also mparhack, probably.

share|improve this answer
add comment

Have you looked at the raggedrightboxes option of the ragged2e package? It almost achieves what you're looking for. :-) Unfortunately, there's no raggedboxes option, but that's easily fixed, as the remainder of this example explains.

Create a copy of the ragged2e.sty (which should be located under TEXHOME/texmf-dist/tex/latex/ms/) and name the new file (say) newragged2e.sty. The relevant lines of the package file are 84 to 115 (at least in my copy of the package). First, copy and paste this range of lines verbatim to immediately after this range. Next, change the first line,

\newcommand*{\@raggedtwoe@raggedrightboxes@opt}{

to

\newcommand*{\@raggedtwoe@raggedboxes@opt}{

and change the last line,

\DeclareOption{raggedrightboxes}{\@raggedtwoe@raggedrightboxes@opt}

to

\DeclareOption{raggedboxes}{\@raggedtwoe@raggedboxes@opt}

Third, replace the instruction

  \RaggedRight

located towards the end of the \@arrayparboxrestore command with

  \raggedouter

where \raggedouter is defined in your code example. (Note for readers other than the OP: the command \checkoddpage that is used in the definition of the raggedouter command is provided by the changepage package.) Run texhash (if needed) to make your TeX system aware of the new package myragged2e. Finally, load the myragged2e package with the raggedboxes option set, and you should be in business. :-)

share|improve this answer
    
And while your doing this, contact the author of ragged2e (me :) and pitch your idea. –  Martin Schröder Oct 20 '11 at 21:00
    
@MartinSchröder: Let me hereby pitch the idea of adding a "raggedboxes" option to the ragged2e package. :-) A different concern: While it may be worthwhile implementing an option to have all marginpar boxes be set RaggedRight/RaggedLeft, depending on whether they appear on recto/verso pages, providing an option that makes all boxes (incl. minipages, etc.) adhere to this style may be overkill. How providing an option "RaggedMarginpars" which affects only marginpar boxes and implements the OP's RaggedOuter idea, with RaggedRight in effect unless it's a two-sided document? Thanks. –  Mico Oct 20 '11 at 21:31
    
And why is that better than the answer by egreg (\marginpar/mparhack) above? –  Martin Schröder Oct 20 '11 at 21:42
    
@MartinSchröder: I'm puzzled by your question -- where or when did I state that this suggestion was better than egreg's? I thought you were asking me a real question about my suggested solution, so I tried to provide further information what I was thinking about. If this was not the purpose of your question, I apologize sincerely for misunderstanding it. OK? –  Mico Oct 20 '11 at 21:48
2  
The \raggedouter macro in ragged2e would give people more options. It is also defined in the tufte-latex package, that defines its own floats and does not use marginpar. Also, it is not a good reason, but marginfix has a bug that prevents me from using /marginpar[\raggedleft]{\raggedright} solution. –  Andy Oct 21 '11 at 5:05
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.