LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1021|回复: 1

emacs搜索-替换问题

[复制链接]
发表于 2009-4-25 20:39:40 | 显示全部楼层 |阅读模式
有个latex文档,里面有很多内容被显示成红色,命令是
\textcolor{red}{xxx}
其中xxx就是被显示成红色的内容,但是xxx里面可能嵌套了其它的latex内容,比如引用一个公式如下
\textcolor{red}{xxx\eqref{eqn:a}xxx}
甚至嵌套了更多的显示红色命令,比如在正文中插入一个脚注,又把脚注部分内容显示成红色
\textcolor{red}{xxx\footnote{xxx\textcolor{red}{xxx}}xxx}

现在想写个命令把所有红色消除,即把\textcolor{red}{xxx}改为xxx,把
\textcolor{red}{xxx\footnote{xxx\textcolor{red}{xxx}}xxx}
改为
xxx\footnote{xxxxxx}xxx

文档中需要作数百处改动,希望写个命令在emacs里面搜索替换,特请教大家。谢谢。
发表于 2009-5-6 11:06:50 | 显示全部楼层
Post by Dirac2003;1979474

现在想写个命令把所有红色消除,即把\textcolor{red}{xxx}改为xxx


You (or the original tex file) really misunderstand the spirit of (la)tex. Long story short, you don't define how things looks, but define what things are.

For your case, what if, say, several versions later, you decide (or it is required) to use back the red highlighting?

The best approach, define a command, which explains what are you defining, say KeywordRed, as:

\newcommand{\KeywordRed}[1]{
\textcolor{red}{#1}
}

then replace all \textcolor{red} with \KeywordRed.

If you want to disable red highlighting, do

\newcommand{\KeywordRed}[1]{
%\textcolor{red}{#1}
#1
}

which makes it very easy for you if you decide to change your mind.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表