3

At the moment I'm working on a little report. Therefore I had to redefine the \marginpar{} command new because I wanted it in a smaller font-size compared to the 'normal text'. The code I've written is the following one:

\documentclass{scrbook}

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{mparhack}    
\usepackage{calc}    

\setlength{\fboxsep}{1pt}

\makeatletter

\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\oldmarginpar[\color{black}\scriptsize #1]%
{\color{black}\scriptsize #1}}

\makeatother

\begin{document}
\chapter{Hello everybody!}

... but anyway, it's interesting. \marginpar{I don't know why there's some space ... ?}

\end{document}

Now, there's an image to show the appearing problem: Problem with vertical space

I don't know why, but after my redefinition, there's some vertical space before the margin par added. It does no longer start at the same line like the 'normal text'.

So my question is, how can I redefine the \marginpar in that way that it will always start at the 'upper line' of the 'normal text'. In the image given above I want the \marginpar-text to appear on the blue line - the 'normal text' and the \marginpar-text should use the same first 'upper line'. (Unfortunately I don't know the exact typographic names for the things I described here, but I hope, you can help me and understand what I mean ...)

Thanks in advance, eniem

  • 1
    Try \leavevmode before the \color command. – Stephan Lehmke May 28 '14 at 14:16
  • @daleif Thank you! That works fine! But, is there a possibility also to lift the \marginpar-Text up to the 'upper line' of the 'normal-text'? – eniem May 28 '14 at 14:58
  • @eniem, I only fixed your markup. See Stephans comment or Harish's answer. – daleif May 28 '14 at 15:07
  • @daleif ah. I see ... so, @Stephan Lehmke Thank you! That works fine! But, is there a possibility also to lift the \marginpar-Text up to the 'upper line' of the 'normal-text'? – eniem May 28 '14 at 15:23
  • 1
    @eniem This might be possible, but I advise strongly against it. In all typography, the base line (i.e. the line on which the letters "stand"; the red line in your image) is the point of vertical alignment. So the correct alignment looks like the image by Harish. – Stephan Lehmke May 28 '14 at 15:27
3

You have to use \textcolor instead of \color:

\documentclass{scrbook}

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{mparhack}
\usepackage{calc}

\setlength{\fboxsep}{1pt}

\makeatletter

\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\oldmarginpar[\textcolor{black}{\scriptsize #1}]%
{\textcolor{black}{\scriptsize #1}}}

\makeatother

\begin{document}
\chapter{Hello everybody!}

... but anyway, it's interesting. \marginpar{I don't know why there's some space ... ?}

\end{document}

enter image description here

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.