我目前正在使用书籍类,并用它marginpar
来引用来源。我希望右页的边距左对齐,左页的边距右对齐。有什么办法吗?
注意:由于包不兼容,我无法使用 marginnote。
\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in, outer=2in, marginparsep=.1in, headsep=16pt]{geometry}
\usepackage{lipsum}
\begin{document}
\marginpar{This is the outside margin. I would like it to be aligned left (as it is).}\lipsum[1]
\clearpage
\marginpar{This is also the outside margin. I would like it to be aligned right}\lipsum[2]
\end{document}
答案1
这将实现自动化本·斯特恩的回答使用 KOMA 脚本测试\ifthispageodd
(通过scrextend
给出类的用途book
)并定义一个\alignedmarginpar
在左页面上右对齐的。
\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in,
outer=2in, marginparsep=.1in, headsep=16pt]{geometry}
\usepackage{scrextend}
\usepackage{lipsum}
\newcommand{\alignedmarginpar}[1]{%
\ifthispageodd{%
\marginpar{\raggedright\small #1}}{%
\marginpar{\raggedleft\small #1}}%
}
\begin{document}
\alignedmarginpar{This is the outside margin. I would like it to be aligned left (as it is).}\lipsum[1]
\clearpage
\alignedmarginpar{This is also the outside margin. I would like it to be aligned right.}\lipsum[2]
\end{document}
答案2
有一个可选参数\marginpar
允许指定左侧文本。这允许创建\alignedmarginpar
从中创建解决方案gusbrs 的回答无需额外的软件包:
\newcommand{\alignedmarginpar}[1]{%
\marginpar[\raggedleft #1]{\raggedright #1}%
}
答案3
\raggedleft
在文本前加上一个\marginpar
。
\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in,
outer=2in, marginparsep=.1in, headsep=16pt]{geometry}
\usepackage{lipsum}
\begin{document}
\marginpar{This is the outside margin. I would like it to be aligned left (as it
is).}\lipsum[1]
\clearpage
\marginpar{\raggedleft This is also the outside margin. I would like it to be
aligned right}\lipsum[2]
\end{document}
答案4
为了补充@gusbrs 和@egreg 的出色回答,如果您想复制\marginpar[inner margin text]{outer margin text}
允许根据使用的边距排版不同文本的行为(对于twoside
d 文档),您也可以使用包进行以下定义xparse
,
\documentclass[twoside]{book}
\usepackage[paperheight=5in,paperwidth=6in,top=.7in,bottom=.7in, inner=1in, outer=2in, marginparsep=.1in, headsep=16pt]{geometry}
\usepackage{lipsum}
\usepackage{xparse}
\NewDocumentCommand{\raggedmarginpar}{ O{#2} m }{%
\marginpar[\raggedleft#1]{\raggedright#2}%
}
\begin{document}
\raggedmarginpar{This is the outside margin. I would like it to be aligned left (as it is).}\lipsum[1]
\clearpage
\raggedmarginpar{This is also the outside margin. I would like it to be aligned right}\lipsum[2]
\clearpage
\raggedmarginpar[Points towards main text.~$\Rightarrow$]{$\Leftarrow$~Points towards main text.}\lipsum[3]
\clearpage
\raggedmarginpar[Points towards main text.~$\Rightarrow$]{$\Leftarrow$~Points towards main text.}\lipsum[4]
\end{document}