调整边距后修复边注位置

调整边距后修复边注位置

我正在尝试在页边距中记一些笔记,这些笔记将出现在印刷版中。我希望使用它来adjmulticols调整文档中两列文本的页边距,以便节省空间。不幸的是,导致marginnote与我的文本发生冲突,这里是一个例子:

\documentclass{article}
\usepackage{lipsum,multicol}
\usepackage{marginnote}
\usepackage{adjmulticol}
\begin{document}
Here I have some text that is in a single regular column.
 It is not very interesting, but it should illustrate the purpose here.
 \marginnote{Here is a margin note, that should look fine}
 I'm sure you can come up with something more interesting, but 
 that isn't the point here, it is just to have some text in a single column.
 Just so you don't have to read this crap the whole time, I'll give you
 something worth reading.
\begin{adjmulticols}{2}{-7.5 ex}{-7.5ex}
I had called upon my friend Sherlock Holmes upon the second
morning after Christmas, with the intention of wishing him the
compliments of the season. He was lounging upon the sofa in a
purple dressing-gown, a pipe-rack within his reach upon the
right, and a pile of crumpled morning papers, evidently newly
studied, near at hand. Beside the couch was a wooden chair, and
on the angle of the back hung a very seedy and disreputable
\marginnote{This is an ugly hat, and an ugly margin note}
hard-felt hat, much the worse for wear, and cracked in several
places. A lens and a forceps lying upon the seat of the chair
suggested that the hat had been suspended in this manner for the
purpose of examination.

"You are engaged," said I; "perhaps I interrupt you."

"Not at all. I am glad to have a friend with whom I can discuss
my results. The matter is a perfectly trivial one"--he jerked his
thumb in the direction of the old hat--"but there are points in
connection with it which are not entirely devoid of interest and
even of instruction."

I seated myself in his armchair and warmed my hands before his
crackling fire, for a sharp frost had set in, and the windows
were thick with the ice crystals. "I suppose," I remarked, "that,
homely as it looks, this thing has some deadly story linked on to
it--that it is the clue which will guide you in the solution of
some mystery and the punishment of some crime."

"No, no. No crime," said Sherlock Holmes, laughing. "Only one of
those whimsical little incidents which will happen when you have
four million human beings all jostling each other within the
space of a few square miles. Amid the action and reaction of so
dense a swarm of humanity, every possible combination of events
may be expected to take place, and many a little problem will be
presented which may be striking and bizarre without being
criminal. We have already had experience of such."

"So much so," I remarked, "that of the last six cases which I
have added to my notes, three have been entirely free of any
legal crime."
\end{adjmulticols}
\end{document}

这会产生以下输出,这显然不太好。作为附带奖励,我如何让这个注释位于另一侧?我知道这应该很容易,但我还没有在文档中找到它。 丑陋的保证金说明

答案1

此解决方案提供了一种可能的解决方法。使用adjustwidthfrom changepage package。在 adjustwidth 环境中,可以调整左右边距。该环境采用两个必需的长度参数:

\begin{adjustwidth}{<leftmargin>}{<rightmargin>} ... \end{adjustwidth}

正长度值将增加相关边距(缩短文本行),而负长度值将减少边距(延长文本行)。空长度参数表示边距不变。在环境结束时,边距将恢复为其原始值。

这里\mymarginnote定义了一个带有 3 个参数的宏。#1=leftmargin、#2=rightmargin 和 #3= 文本内容。红色文本表示需要改进的情况,而蓝色文本表示建议的更正。

在此处输入图片描述

代码

\documentclass{article}
\usepackage{lipsum,multicol}
\usepackage{marginnote,xcolor}
\usepackage{changepage}
\usepackage{adjmulticol}

\newcommand{\mymarginnote}[3]{\marginnote{\begin{adjustwidth}{#1}{#2} 
\color{blue}            % This is for clarity purpose, can be removed 
#3
\end{adjustwidth}}
}
\begin{document}
Here I have some text that is in a single regular column.
 It is not very interesting, but it should illustrate the purpose here.
 \marginnote{Here is a margin note, that should look fine}
 I'm sure you can come up with something more interesting, but 
 that isn't the point here, it is just to have some text in a single column.
 Just so you don't have to read this crap the whole time, I'll give you
 something worth reading.
\begin{adjmulticols}{2}{-7.5 ex}{-7.5ex}
I had called upon my friend Sherlock Holmes upon the second
morning after Christmas, with the intention of wishing him the
compliments of the season. He was lounging upon the sofa in a
purple dressing-gown, a pipe-rack within his reach upon the right, and a pile of
crumpled morning papers, evidently newly studied, near at hand. Beside the couch was
a wooden chair, and on the angle of the back hung a very seedy and disreputable
\marginnote{\begin{adjustwidth}{}{}% no change of margin
\color{red}This is an ugly hat, and an ugly margin note
\end{adjustwidth}}
\mymarginnote{6ex}{} 
{This is an ugly hat, and an ugly margin note}[1.5cm] % increase the left margin
\reversemarginpar % to show on the other side
\mymarginnote{-5ex}{6ex}
{This is an ugly hat, and an ugly margin note}[1.5cm] % decrease the left margin and increase the right margin 
hard-felt hat, much the worse for wear, and cracked in several
places. A lens and a forceps lying upon the seat of the chair
suggested that the hat had been suspended in this manner for the
purpose of examination.

"You are engaged," said I; "perhaps I interrupt you."

"Not at all. I am glad to have a friend with whom I can discuss
my results. The matter is a perfectly trivial one"--he jerked his
thumb in the direction of the old hat--"but there are points in
connection with it which are not entirely devoid of interest and
even of instruction."

I seated myself in his armchair and warmed my hands before his
crackling fire, for a sharp frost had set in, and the windows
were thick with the ice crystals. "I suppose," I remarked, "that,
homely as it looks, this thing has some deadly story linked on to
it--that it is the clue which will guide you in the solution of
some mystery and the punishment of some crime."

"No, no. No crime," said Sherlock Holmes, laughing. "Only one of
those whimsical little incidents which will happen when you have
four million human beings all jostling each other within the
space of a few square miles. Amid the action and reaction of so
dense a swarm of humanity, every possible combination of events
may be expected to take place, and many a little problem will be
presented which may be striking and bizarre without being
criminal. We have already had experience of such."

"So much so," I remarked, "that of the last six cases which I
have added to my notes, three have been entirely free of any
legal crime."
\end{adjmulticols}
\end{document}

相关内容