【发布时间】:2021-05-22 10:42:17
【问题描述】:
我正在处理 LaTeX beamer 演示文稿,我想在每个 \item 标题下方添加一个注释部分,它只是复制其文本。例如我有
\begin{frame}{Frame Title}
\begin{itemize}[<+->]
\item Einstein was a clever man.
\item My favorite equation is,
\begin{equation}
E = m c^2.
\end{equation} where
\begin{enumerate}
\item $m$ is the mass,
\item $c$ the velocity of light and,
\item $E$ is the energy.
\end{enumerate}
\end{itemize}
\end{frame}
我想拥有
\begin{frame}{Frame Title}
\begin{itemize}[<+->]
\item Einstein was a clever man.
\note<.>[item]{
Einstein was a clever man.
}
\item My favorite equation is,
\begin{equation}
E = m c^2.
\end{equation} where
\begin{enumerate}
\item $m$ is the mass,
\item $c$ the velocity of light and,
\item $E$ is the energy.
\end{enumerate}
\note<.>[item] {
My favorite equation is,
\begin{equation}
E = m c^2.
\end{equation where
\begin{enumerate}
\item $m$ is the mass,
\item $c$ the velocity of light and,
\item $E$ is the energy.
\end{enumerate}
}
\end{itemize}
\end{frame}
如何在vim 中或使用awk 或sed 等命令行工具执行此操作?
通过vim,我可以复制并附加以\item 模式开头的独立行
:g/^\\item/ copy . | s//\\note\{item\}<.>\{/g
但我无法捕获属于每个顶级\item 的整个块。
【问题讨论】:
-
请在您的问题中添加您的努力,我们非常鼓励您这样做,谢谢。
-
期望结果和原始状态之间的差异与以下问题不一致:a)没有提到调整缩进或应该或不应该嵌套什么,b)要求发生一些事情“在每个
\item"下方。 -
感谢@romainl 指出这一点。我已经修复了缩进,并且我希望每个顶级
\item列表在它们下方但在\note<.>[item]{...}块内重复。