如下图所示,当我高亮显示交叉线文本时,同一行的边注中的文本颜色也会改变。
代码如下:
\documentclass[onecolumn]{revtex4-1}
\usepackage{soul}
\usepackage{color, xcolor}
\usepackage{geometry}
\geometry{ a4paper, total={10cm,257mm}, left=10mm, top=20mm, }
\begin{document}
\setlength\marginparwidth{8cm}
\setlength\marginparsep{0.6cm}
aaa
\sethlcolor{yellow}\hl{bbb}\marginpar{\scriptsize{\textbf{bbb:}}}
ccc dddd eeee ffff ggggg hhhhhh iiiiiii jjjjjjjj \
\sethlcolor{yellow}\hl{kkkkkkkkk kkkkkkkkkkk}
\marginpar{\scriptsize{\textbf{kkkkkkkkk kkkkkkkkkkk:} }}
aaa
\sethlcolor{yellow}\hl{bbb}\marginpar{\scriptsize{\textbf{bbb:} }}
ccc dddd eeee ffff ggggg hhhhhh iiiiiii jjjjjjjj
\sethlcolor{pink}
\hl{kkkkkkkkk kkkkkkkkkkk}
\marginpar{\scriptsize{\textbf{kkkkkkkkk kkkkkkkkkkk:} }}
\end{document}
有办法解决这个问题吗?
答案1
平均能量损失
\documentclass[onecolumn]{revtex4-1}
\usepackage{soul}
\usepackage{color, xcolor}
\usepackage{geometry}
\geometry{ a4paper, total={10cm,257mm}, left=10mm, top=20mm, }
\makeatletter
\usepackage{etoolbox}
\patchcmd{\@savemarbox}{\color@vbox}{\color@vbox\normalcolor}{}{}
\makeatother
\begin{document}
\setlength\marginparwidth{8cm}
\setlength\marginparsep{0.6cm}
aaa
\sethlcolor{yellow}\hl{bbb}\marginpar{\scriptsize{\textbf{bbb:}}}
ccc dddd eeee ffff ggggg hhhhhh iiiiiii jjjjjjjj \
\sethlcolor{yellow}\hl{kkkkkkkkk kkkkkkkkkkk}
\marginpar{\scriptsize{\textbf{kkkkkkkkk kkkkkkkkkkk:} }}
aaa
\sethlcolor{yellow}\hl{bbb}\marginpar{\scriptsize{\textbf{bbb:} }}
ccc dddd eeee ffff ggggg hhhhhh iiiiiii jjjjjjjj
\sethlcolor{pink}
\hl{kkkkkkkkk kkkkkkkkkkk}
\marginpar{\scriptsize{\textbf{kkkkkkkkk kkkkkkkkkkk:} }}
\end{document}
编辑该\patchcmd
命令只是在\@savemarbox
命令内部查找,搜索\color@vbox
并用 替换它\color@vbox\normalcolor
。当然,您可以\patchcmd
通过\@savemarbox
直接重新定义来避免使用:
\makeatletter
\long\def \@savemarbox #1#2{%
\global\setbox #1%
\color@vbox\normalcolor% <--- added \normalcolor here ---
\vtop{%
\hsize\marginparwidth
\@parboxrestore
\@marginparreset
#2%
\@minipagefalse
\outer@nobreak
}%
\color@endbox
}
\makeatother