![边注与主要段落的对齐方式独立](https://linux22.com/image/290331/%E8%BE%B9%E6%B3%A8%E4%B8%8E%E4%B8%BB%E8%A6%81%E6%AE%B5%E8%90%BD%E7%9A%84%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F%E7%8B%AC%E7%AB%8B.png)
我注意到,当\marginnote
添加 (编辑:使用 marginnote 包) 时,该注释的水平对齐方式会从注释放置的位置继承。就我而言,我希望在节标题内定义边注,从而使边注居中。
如果我尝试向指令添加\raggedleft
或添加\raggedright
,那么它要么被忽略,要么覆盖节标题的格式(取决于它是在左边距还是右边距)。
是否有某种方法可以独立于定义边距文本的文本来改变边距文本的水平对齐方式?
编辑:抱歉,在构建最小工作示例时,我意识到我令人尴尬地忽略了如何(几乎肯定是错误的)设置节标题居中的重要细节。下面是我想要的最小工作示例。
\documentclass{article}
\RequirePackage{sectsty}
\allsectionsfont{\centering\sc} % <-- this is probably wrong!
\usepackage[fulladjust]{marginnote}
\begin{document}
\section*{This is a section header\marginnote{I really really want this
margin note to be raggedright, and not centred like it is here.}}
\end{document}
需要注意的另一点是,我实际上希望根据注释是在左边距还是右边距,将文本向左或向右对齐。这意味着我认为做需要改变边距文本的对齐方式。
答案1
我假设(但您没有说)您正在使用包\marginnote
中的对齐方式marginnote
。这就像标准一样,\marginpar
不会选择当前对齐方式。以下显示注释是正常对齐的,无论是在两端对齐的段落中使用,还是在左对齐或居中对齐的段落中使用。
\documentclass{article}
\usepackage{marginnote}
\begin{document}
one two three one two three one two three one two three one two three one two three%
\marginnote{a a a a a a a a a a}
one two three one two three one two three one two three one two three one two three
\begin{flushleft}
one two three one two three one two three one two three one two three one two three%
\marginnote{a a a a a a a a a a}
one two three one two three one two three one two three one two three one two three
\end{flushleft}
\begin{center}
one two three one two three one two three one two three one two three one two three%
\marginnote{a a a a a a a a a a}
one two three one two three one two three one two three one two three one two three
\end{center}
\end{document}
sectsty
正在做一些奇怪的事情,懒得去调试,所以只需重新声明 marginpar/marginnote 所做的字体和对齐的规范化,但这个规范化在某个地方被破坏了。这在一侧左边不整齐,在另一侧右边不整齐,这对于 marginnote 来说是正常的。
\documentclass[twoside]{article}
\RequirePackage{sectsty}
\allsectionsfont{\centering\sc} % <-- this is probably wrong!
\usepackage[fulladjust]{marginnote}
\makeatletter
\renewcommand\marginfont{\normalfont}
\renewcommand\raggedleftmarginnote{\@parboxrestore\@marginparreset\raggedleft}
\renewcommand\raggedrightmarginnote{\@parboxrestore\@marginparreset\raggedright}
\makeatother
\begin{document}
\section*{This is a section header\marginnote{I really really want this
margin note to be raggedright, and not centred like it is here.}}
\clearpage
\section*{This is a section header\marginnote{I really really want this
margin note to be raggedright, and not centred like it is here.}}
\end{document}