我如何突出显示包含引用和显示方程式的文本块?

我如何突出显示包含引用和显示方程式的文本块?

我正在处理一篇科学文章的审稿人评论。我想突出显示重大更改,以便审稿人更容易发现这些更改。但是,我发现在使用 soul 包并将任何显示方程式或引文包装在

\hl{ ... }

这会破坏编译。

举个例子,突出显示本文档中的段落需要打开和关闭多个\hls:

\documentclass{article}

\usepackage{soul}
\usepackage[usenames,dvipsnames]{xcolor}

\begin{document}

\hl{This is a sentence with a citation}~\cite{lamport94}.
\hl{This is a sentence with another citation}~\cite{lamport94}.
\hl{Here is a display equation,}
\begin{equation}
  2 + 2 = 4
\end{equation}
\hl{where $4$ is the number that comes after $3$.}

\begin{thebibliography}{9}

\bibitem{lamport94}
  Leslie Lamport,
  \textit{\LaTeX: a document preparation system},
  Addison Wesley, Massachusetts,
  2nd edition,
  1994.

\end{thebibliography}

\end{document}

我更希望:

\documentclass{article}

\usepackage{soul}
\usepackage[usenames,dvipsnames]{xcolor}

\begin{document}

\hl{
This is a sentence with a citation~\cite{lamport94}.
This is a sentence with another citation~\cite{lamport94}.
Here is a display equation,
\begin{equation}
  2 + 2 = 4
\end{equation}
where $4$ is the number that comes after $3$.
}

\begin{thebibliography}{9}

\bibitem{lamport94}
  Leslie Lamport,
  \textit{\LaTeX: a document preparation system},
  Addison Wesley, Massachusetts,
  2nd edition,
  1994.

\end{thebibliography}

\end{document}

但这会破坏编译。

我已经看到了答案如何突出显示包含词汇表和引文的文本?,但这似乎相当混乱。我有很多引用和显示方程式(以及方程式引用、章节引用、列表等),并且不想将所有内容包裹在括号中\mbox或使用额外的括号。有没有更干净的解决方案?注意:这纯粹是为了审阅者的参考,所以它不需要看起来很完美。

答案1

这个问题有很多变体。虽然我第一次阅读它们时没有找到令人满意的答案,但事实证明,这个问题的公认答案的最后如何在修订稿中突出显示引用成功了。具体来说,答案建议定义一个新的环境

\newenvironment{hlbreakable}%
{\color{red}}%
{}

虽然不是最漂亮的,但效果很好。完整示例:

\documentclass{article}

\usepackage{soul}
\usepackage[usenames,dvipsnames]{xcolor}

\newenvironment{hlbreakable}%
{\color{red}}%
{}

\begin{document}

\begin{hlbreakable}
This is a sentence with a citation~\cite{lamport94}.
This is a sentence with inline math, $2 + 2 = 4$.
Here is a display equation,
\begin{equation}
  2 + 2 = 4
\end{equation}
where $4$ is the number that comes after $3$.
\end{hlbreakable}

\begin{thebibliography}{9}

\bibitem{lamport94}
  Leslie Lamport,
  \textit{\LaTeX: a document preparation system},
  Addison Wesley, Massachusetts,
  2nd edition,
  1994.

\end{thebibliography}

\end{document}

编译并给出所需的结果。

相关内容