1

I have a co-worker to edit LaTeX document.

The co-worker uses LaTeX \color and \sout command to make the changs visible in pdf file.

For example, Hello world becomes Hell{\color{red}\sout{o}a} world. What I do is remove the tags to make it Hella world. Can I make the process automatically?

What I want to do is that if I put a cursor on { and press assigned key, emacs will remove everything \color{red}\sout{...} including the outer brackets to leave only a.

3

You do not even need to place the cursor on that {. Using the built-in query-replace-regexp command (bound to C-M-% by default), you can do that \color{red}\sout{...} replacement either one-by-one by reviewing each replacement or in one fell swoop.

Here's how to do those replacements in the whole document instantly.

  1. Go to the beginning of the document by doing M-< or M-x beginning-of-buffer.
  2. Do C-M-% or M-x query-replace-regexp and enter {\\color{red}\\sout{.*?}\(.*?\)} as the search pattern and \1 as the replacement string.
  3. Hit ! to do the replacements in the whole document. (Or you can hit y/n as appropriate as you review each replacement about to happen.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.