在下面的 MWE 中,我们可以看到页边距中的注释向下移动。如果删除几个字母,页边距就会与文本正确对齐。
我更喜欢使用 \myrightmargin,而不是修改 \marginpar 命令。我使用 \reversemarginpar(它是最佳的吗?),因为我使用类文章的 twoside 选项,并且我希望注释始终在右侧!
如何将边注粘贴至文本的同一行?
\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}
嗯,我的第一个带有 $..$ 的边注在左边;我不明白为什么。
答案1
您在行尾引入了大量空白,无论是在文档中的 marginpar 命令之前还是在命令定义中。
\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}