1

I've done the following:

enter image description here

And I'm trying to make a simple line to separate the text from the margin notes. It's the same as the answer in this question, but it seems too complicated to implement (or perhaps I'm too stupid, that's also a valid hypothesis). I'd like something simple to separate the note from the text. This is the my code.

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{relsize}
\usepackage{marginnote}
\usepackage[top=1.5cm, bottom=1.5cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=6.5cm, marginparsep=-2cm]{geometry}

\begin{document}

\marginnote{\begin{eqnarray*}
  {n!}&=&{(n)(n-1)!} \\ 
  {(n+1)!}&=&{(n+1)(n) (n-1)!} 
\end{eqnarray*}
}[2.6cm]


\begin{eqnarray*}
  {\frac{\mathlarger{\prod_{j=0}^{n}(j+1)}}{\mathlarger{‎‎\sum_{i=1}^{n}i}}}&=&{\frac{(j+1)!}{\frac{n(n+1)}{2}}} \\ 
  {}&=&{\frac{2(n+1)!}{n(n+1)}} \\
  {}&=&{\frac{(2)(n+1)(n) (n-1)!}{(n)(n+1)}} \\
  {}&=&{2(n-1)!} 
\end{eqnarray*}

\begin{eqnarray*}
  {\frac{\mathlarger{\prod_{j=1}^{n}j}}{\mathlarger{‎‎\prod_{i=p+1}^{n-1}i}\cdot \mathlarger{‎‎\prod_{k=1}^{p}k} }}&=&{    \frac{n!}{? \cdot k!}                                       } \\ 
  {}&=&{}
\end{eqnarray*}


\end{document}

2 Answers2

1

The height of a \parbox[c] is the distance from the top to the center, so while it may look like the line is twice as big as it should be, it isn't.

BTW, your margin note is way too wide, as demonstrated by the first \rule.

margin note

\documentclass{article}
\usepackage[right=2.5in]{geometry}
\usepackage{mathtools}
\usepackage{marginnote}

\newsavebox{\tempbox}
\newlength{\tempheight}

\begin{document}

\marginnote{\rule{\marginparwidth}{1pt}}

\savebox{\tempbox}{\parbox{\marginparwidth}{% compute height of note
\begin{eqnarray*}
{n!}&=&{(n)(n-1)!} \\ 
{(n+1)!}&=&{(n+1)(n) (n-1)!} 
\end{eqnarray*}
}}%
\settoheight{\tempheight}{\usebox{\tempbox}}%
\marginnote{\hspace{-2pt}\rule[-\tempheight]{.5pt}{2\tempheight}\hspace{1.5pt}% draw line
\usebox{\tempbox}}[2.6cm]

\end{document}

If you want to put a line on every page, try this.

\documentclass{article}
\usepackage[right=6cm]{geometry}
\usepackage{everypage}

\setlength{\marginparwidth}{5cm}

\newlength{\headoffset}
\setlength{\headoffset}{\topmargin}
\addtolength{\headoffset}{\headheight}
\addtolength{\headoffset}{\headsep}
\newcommand{\MarginLine}{\raisebox{-\headoffset}[0pt][0pt]{% to top of text area
\hspace{\oddsidemargin}\hspace{\textwidth}% to right margin
\hspace{0.45\marginparsep}\rule[-\textheight]{0.1\marginparsep}{\textheight}}}% center of marginsep
\AddEverypageHook{\MarginLine}

\begin{document}
\noindent\rule{\textwidth}{1pt}%
\marginpar{Margin notes go here}
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
1

In case you are interested in how to use the solution from Inserting a line to separate the text and the margin note, you simply need to include the appropriate code in your document, and use \marginpar:

enter image description here

Notes:

  • You should avoid using eqnarray as per: eqnarray vs align
  • I changed the code to use align and to get the proper math spacing you should use &= and not &=&.
  • You should not have blank lines between display math environments. Otherwise you end up with excessive white space.
  • I'd recommend you put the code between the %% ------------------ in an external file so you don't need to look at it

Code:

\documentclass[twoside]{article}
\usepackage{amsmath}
\usepackage{relsize}
\usepackage{marginnote}
\usepackage[top=1.5cm, bottom=1.5cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=6.5cm, marginparsep=-2cm]{geometry}

\usepackage{etoolbox} \usepackage{xcolor} %% ------------------ %% Following from https://tex.stackexchange.com/questions/89322/inserting-a-line-to-separate-the-text-and-the-margin-note % patching the OR of LaTeX: \makeatletter \patchcmd{@addmarginpar}% {\box @marbox}% {\hbox{% \ifmpar@rule@rside \hskip-\mparrulefactor\marginparsep\mparrule \hskip\mparrulefactor\marginparsep \fi \box @marbox \ifmpar@rule@lside \hskip\mparrulefactor\marginparsep\mparrule \fi}% \global\mpar@rule@lsidefalse \global\mpar@rule@rsidefalse }% {\typeout{*** SUCCESS *}}{\typeout{* FAIL ***}}

\patchcmd{@addmarginpar}% {\global\setbox@marbox\box@currbox}% {\global\setbox@marbox\box@currbox \global\mpar@rule@lsidetrue \else \global\mpar@rule@rsidetrue }% {\typeout{*** SUCCESS *}}{\typeout{* FAIL ***}}

\newif\ifmpar@rule@lside \newif\ifmpar@rule@rside \makeatother

% \mparrule generates the \vrule but should use no space horizontally % using color is just for fun ... \newcommand\mparrule{\textcolor{blue}{\hskip-.2pt\vrule\hskip-.2pt}}

% placement factor: .5 places the rule midway in the space made available % by \marginparsep \newcommand\mparrulefactor{.5} \normalmarginpar %% ------------------

\begin{document} Here is an equation: \marginpar{\begin{align} {n!}&={(n)(n-1)!} \ {(n+1)!}&={(n+1)(n) (n-1)!} \end{align}% }% \begin{align} {\frac{\mathlarger{\prod_{j=0}^{n}(j+1)}}{\mathlarger{‎‎\sum_{i=1}^{n}i}}}&={\frac{(j+1)!}{\frac{n(n+1)}{2}}} \ {}&={\frac{2(n+1)!}{n(n+1)}} \ {}&={\frac{(2)(n+1)(n) (n-1)!}{(n)(n+1)}} \ {}&={2(n-1)!} \end{align} an another one: \begin{align} {\frac{\mathlarger{\prod_{j=1}^{n}j}}{\mathlarger{‎‎\prod_{i=p+1}^{n-1}i}\cdot \mathlarger{‎‎\prod_{k=1}^{p}k} }}&={ \frac{n!}{? \cdot k!} } \ {}&={} \end{align} \end{document}

Peter Grill
  • 223,288