2

In the following MWE, we can see that the notes in the margin are shifted downwards. If a few letters are removed, the margin is properly aligned with the text.

I prefer to use \myrightmargin instead of modifying the \marginpar command. I use \reversemarginpar (is it optimal ?) for I use the twoside option of the class article and for I want the notes to be always on the right !

How to glue the margin notes to the same line of the text ?

   \documentclass[twoside, a4paper, 11pt]{article}
%\usepackage{marginnote}

\usepackage{lipsum}

\setlength{\parindent}{0ex}

\newcommand{\myrightmargin}[1]{
\reversemarginpar
\marginpar{
{#1}
}
}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}


\section{first section}
    $
j=kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
$
\marginpar{
%\hspace*{-1.1\marginparsep}
the margin
}

\lipsum[1-8]
random text to get closer to the right margin;random text to get closer too.
\marginpar{
%\hspace*{-1.1\marginparsep}
the margin
}


random text to get closer to the right margin;random text to get closer too.
\myrightmargin{my second margin}



\end{document}

Well my first margin note with $..$ is on the left; I do not see why.

3

You introduced a lot of white space from ends of lines, both in the document before your marginpar commands and within the command definition.

 \documentclass[twoside, a4paper, 11pt]{article}
%\usepackage{marginnote}

\usepackage{lipsum}

\setlength{\parindent}{0ex}

\newcommand{\myrightmargin}[1]{%
%\reversemarginpar
\marginpar{%
#1%
}%
}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}


\section{first section}
\reversemarginpar

\lipsum[1-8]
random text to get closer to the right margin;random text to get closer too.%
\marginpar{%
%\hspace*{-1.1\marginparsep}
the margin%
}


random text to get closer to the right margin;random text to get closer too.%
\myrightmargin{my second margin}



\end{document}
4
  • Indeed ! So is possible to put \myrightmargin{my second margin} on a newline and still not introducing the spaces ?
    – user50260
    Apr 23 '14 at 1:04
  • I place \removelastskip just before \marginpar{...} in my command. It seems to work.
    – user50260
    Apr 23 '14 at 5:46
  • @Phillip You can use a % as in my edit. Remember TeX is primarily optimised for text and a newline is treated as a space and spaces are not ignored: they typeset spaces between words. I think it is much clearer and robust to not add a space rather than explicitly add a space and then remove it. Apr 23 '14 at 8:44
  • After some tests, \unskip and \removelastskip do work but not for lists ! I have a configuration where there is a display [ ] in the last item of a list and the list itself reaches the bottom of the page. In this case, the margin note goes to the next page !
    – user50260
    Apr 25 '14 at 6:20

Your Answer

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