1

I want to put a note in the margin of my text, but I do not want to change the margins of the entire document. I only want the margins of one or two paragraphs to change so the margin note can be placed next to it. I've looked into marginnote + adjustwidth, but this does not give a good result. The margin note is not occuping the created space. I also tried using marginnote + \newgeometry, but \newgeometry will force a new page to start before and after the encapsulated text, which is sub-optimal. Is there another way to do this?

This is a stand-alone example wherein the two solutions are tried:

\documentclass[11pt,a4paper,twoside]{book}

\usepackage{geometry}
\geometry{papersize={16cm,24cm},layoutsize={16cm,24cm},top=2cm,bottom=2cm,left=2cm,right=2cm}
\usepackage[strict]{changepage}
\usepackage{marginnote}
\usepackage{mparhack}
\usepackage{marginfix}

\begin{document}

%EXAMPLE1
\begin{adjustwidth}{2cm}{}
\reversemarginpar
\marginnote{My margin note text}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. 
\end{adjustwidth}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
%EXAMPLE2
\newgeometry{papersize={16cm,24cm},layoutsize={16cm,24cm},top=2cm, bottom=2cm, outer=4.5cm, inner=2cm, heightrounded, marginparwidth=2.5cm, marginparsep=0.5cm}
\marginnote{My margin note text}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
\restoregeometry
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.

\end{document}

This gives:

Page1page2page3

  • As always on this site: please provide a minimal example, it makes it so much easier to help – daleif Jun 21 '16 at 12:30
  • That is not a minimal example, there is no preamble or document class. It should be an example showing your problem, an example that others can copy and test as is, without having to add anything. Then the version we test is the same you test. – daleif Jun 21 '16 at 12:41
  • @daleif , ok thx for the info – Olivier_s_j Jun 21 '16 at 12:52
  • How fine do you want to be? For entire paragraphs this is easy. – John Kormylo Jun 21 '16 at 12:59
  • Finer than on page level, but not as fine as on a sentence level, so paragraph level sounds perfect. – Olivier_s_j Jun 21 '16 at 13:01
1

This works with both oneside and twoside documents, where the note would automaticly be placed in the outer margin, as one would expect.

I think I may have overdone this, as it turned out a bit more complicated than I had originally thought.

Output

enter image description here

Code

\documentclass[11pt,twoside]{article}
\usepackage{geometry}
\geometry{papersize={16cm,24cm},layoutsize={16cm,24cm},top=2cm,bottom=2cm,left=2cm,right=2cm,marginparwidth=1cm}
\usepackage{calc}
\usepackage{lipsum}
%\usepackage{showframe}
\usepackage{changepage}
\newlength{\tempParIndent}
\newcommand{\textBody}[1]{%
    \begin{minipage}[t]{\linewidth-5cm-\marginparsep}
    \setlength{\parindent}{\tempParIndent}%
        #1
    \end{minipage}%
    }
\newcommand{\noteBody}[1]{%
    \begin{minipage}[t]{5cm}
        #1
    \end{minipage}%
}
\newcommand{\textAndNote}[2]{%
    % input:
    % #1: The main text
    % #2: The note
    \setlength{\tempParIndent}{\parindent}
    \begin{adjustwidth*}{}{-\marginparwidth-\marginparsep}%
    \checkoddpage%
\ifoddpage%
    \textBody{#1}%
    \hspace{\marginparsep}%
    \noteBody{#2}%
\else%
    \noteBody{#2}%
    \hspace{\marginparsep}%
    \textBody{#1}%
\fi%
    \end{adjustwidth*}}
\begin{document}
\lipsum[2]
\vspace{3cm}
\lipsum[2]
\textAndNote{\lipsum[3]}{This is a note.}
\clearpage
\textAndNote{\lipsum[4]}{This is a note, automaticly placed on the correct side.}
\lipsum[5]
\end{document}
  • Nice, would you be able to make it work when using: \geometry{papersize={16cm,24cm},layoutsize={16cm,24cm},top=2cm,bottom=2cm,left=2cm,right=2cm} ? As this is necessary. – Olivier_s_j Jun 21 '16 at 14:12
  • Yes, but I added \marginparwidth=1cm to it. showframeis quite useful here. 1cm is really not much room to work with, here, and I suggest you edit the length of this and the 5cm in both of the minipages. – Runar Jun 21 '16 at 14:21
0

Since \marginparwidth is wider than the margins supplied by geometry, I added \marginparadjust to be the indentation into the margin. Note, this version allows page breaks in the text.

\documentclass[11pt,a4paper,twoside]{book}
\usepackage{geometry}
\geometry{papersize={16cm,24cm},layoutsize={16cm,24cm},top=2cm,bottom=2cm,left=2cm,right=2cm}
\usepackage{ifoddpage}
\usepackage{lipsum}

\newlength{\marginparadjust}% indentation into margin
\setlength{\marginparadjust}{1cm}

\newcommand{\mymarginpar}[2]% #1 = note, #2=text
{\par\checkoddpage\ifoddpage
  \leftskip=\dimexpr \marginparwidth+\marginparsep-\marginparadjust\relax
  \noindent\llap{\hspace{\dimexpr -\leftskip-\marginparadjust}%
  \smash{\parbox[t]{\marginparwidth}{#1}}\hspace{\marginparsep}}%
  \indent #2\par\leftskip=0pt
\else
  \rightskip=\dimexpr \marginparwidth+\marginparsep-\marginparadjust\relax
  \noindent\rlap{\hspace{\dimexpr\textwidth-\rightskip+\marginparsep}%
  \smash{\parbox[t]{\marginparwidth}{#1}}}%
  \indent #2\par\rightskip=0pt
\fi}%

\begin{document}
\lipsum[1]
\mymarginpar{This note is too wide to fit.}{\lipsum[2]}
\lipsum[3]

\newpage
\lipsum[1]
\mymarginpar{This note is too wide to fit.}{\lipsum[2]}
\lipsum[3]

\end{document}

twopages

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.