1

I'm currently using the book class and I'm using marginpar to cite sources. I would like the marginpar on right pages to be aligned left and the marginpar on left pages to be aligned right. Is there any way to do this?

Note I cannot use marginnote due to a package incompatibility.

enter image description here

\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in, outer=2in, marginparsep=.1in, headsep=16pt]{geometry}

\usepackage{lipsum}

\begin{document}

\marginpar{This is the outside margin. I would like it to be aligned left (as it is).}\lipsum[1] 

\clearpage

\marginpar{This is also the outside margin. I would like it to be aligned right}\lipsum[2] 

\end{document}
2

This automates Ben Stern's answer using the KOMA Script test \ifthispageodd (through scrextend given the use of the book class) and defining an \alignedmarginpar which aligns right on left pages.

\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in,
 outer=2in, marginparsep=.1in, headsep=16pt]{geometry}

\usepackage{scrextend}
\usepackage{lipsum}

\newcommand{\alignedmarginpar}[1]{%
    \ifthispageodd{%
        \marginpar{\raggedright\small #1}}{%
        \marginpar{\raggedleft\small #1}}%
    }

\begin{document}

\alignedmarginpar{This is the outside margin. I would like it to be aligned left (as it is).}\lipsum[1]

\clearpage

\alignedmarginpar{This is also the outside margin. I would like it to be aligned right.}\lipsum[2]

\end{document}

enter image description here enter image description here

  • It should be ragged on both sides, isn't? – Sigur Feb 26 '18 at 21:38
  • @Sigur, that's not what I understood from the OP. The text of the two marginpars suggests the alternation of the alignment is the desired result. If your reading is correct, the last comment I left for BenStern was undeserved. – gusbrs Feb 26 '18 at 21:43
  • Ragged, but to different directions. OP wrote would like the marginpar on right pages to be aligned left and the marginpar on left pages to be aligned right. So, the result should be one opposite to the other. So use \raggedright. – Sigur Feb 26 '18 at 21:45
  • @Sigur Aligned doesn't mean ragged necessarily. The OP states on the even page note "I would like it to be aligned left (as it is)". Indeed there is no way to justify the text and align it right. I'm inclined to agree with you that \raggedright on the other side would be more elegant. Given these considerations, do you think this is the proper reading of the OP? (if so, I'll gladly edit). – gusbrs Feb 26 '18 at 21:52
  • 1
    I'd use a small font, since the width is not too big, just to see how pretty it is: \raggedright\small #1. Also, it is more visible the ragged in this case. – Sigur Feb 26 '18 at 22:14
1

Put a \raggedleft right before your \marginpar text.

\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in,
  outer=2in, marginparsep=.1in, headsep=16pt]{geometry}

\usepackage{lipsum}

\begin{document}

\marginpar{This is the outside margin. I would like it to be aligned left (as it
  is).}\lipsum[1]

\clearpage

\marginpar{\raggedleft This is also the outside margin. I would like it to be
  aligned right}\lipsum[2]

\end{document}

demo of latex output

  • 1
    Welcome to TeX.SX! This does indeed achieve the result for this particular marginpar, but it requires that you know which side the marginpar will be beforehand and is all too manual in this respect. And somewhat error prone. Still, a welcome +1. – gusbrs Feb 25 '18 at 21:57
  • Revising, those are fair criticisms. – Ben Stern Feb 26 '18 at 21:32
  • I appreciate your well intended revision. But now, you have all marginpars raggedleft. On both even and odd pages, which explicitly is not what the original post asked for. Your original answer was partial, but went in the intended direction. The revision now leaves your answer as not solving the problem asked for. Have you taken a look at the answer I left automating your initial proposal? – gusbrs Feb 26 '18 at 21:39
  • 1
    My mistake, I somehow confused myself. Reverting. Thank you. I was trying to figure out a solution that didn't need another package, but I think you're right that this needs more automation. – Ben Stern Feb 26 '18 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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