我已完成以下操作:
我试图用一条简单的线将正文与边注分开。这与这个问题,但实现起来似乎太复杂了(或者也许我太笨了,这也是一个有效的假设)。我想要一些简单的东西来将注释与文本分开。这是我的代码。
\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}
答案1
如果你对如何使用解决方案感兴趣插入一条线来分隔正文和边注,您只需在文档中包含适当的代码,然后使用\marginpar
:
笔记:
- 您应避免
eqnarray
按如下方式使用:eqnarray 与 align - 我改变了代码以使用
align
并获得您应该使用的正确的数学间距&=
而不是&=&
。 - 你应该不是在显示数学环境之间留有空行。否则,您最终会得到过多的空白。
- 我建议你将代码放在
%% ------------------
外部文件中,这样你就不需要查看它了
代码:
\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}
答案2
\parbox[c] 的高度是从顶部到中心的距离,因此虽然看起来这条线是其应有大小的两倍,但事实并非如此。
顺便说一句,您的边注太宽了,正如第一个 \rule 所示。
\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}
如果您想在每一页上都放一行,请尝试一下。
\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}