TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm typesetting a document and to make it more editable I'd like to find a nice way to write the document making custom commands left and right for my ease, then go and replace them with their non-custom definitions.

For instance, I have the following defined in a separate preamble file:

\newcommand{\mb}[1]{\mathbb{#1}} 

that simply makes it easier when I'm using blackboard bold characters a bunch throughout the document. However, whoever might be editing the document later might have difficulty parsing the code (he's old, etc.) with my custom commands floating around everywhere. Is there a nice and easy way to go through my document and replace every

\mb{A}

with

\mathbb{A}

so I don't have to sift through hundreds of "replace" dialogues?

This would also help if I want to change the name of a command I've used in previous files.

Edit to add MWE:

\documentclass[12pt]{article}
\usepackage{amssymb}
\newcommand{\mb}[1]{\mathbb{#1}} 
\begin{document}
\mb{R}
\end{document}

to

\documentclass[12pt]{article}
\usepackage{amssymb}
\newcommand{\mb}[1]{\mathbb{#1}} 
\begin{document}
\mathbb{R}
\end{document}
share|improve this question
6  
This is a task for a good editor supporting regular expressions. I use UltraEdit, Emacs and Notepad++ which all support this. – Uwe Ziegenhagen Feb 18 '14 at 6:22
    
That would require learning about regular expressions. Texmaker is my native IDE and I don't know if it supports regular expressions (although I know I can just run them on a different editor). I can bite the bullet and just learn them, but if possible I'd rather just input strings into an existing structure for this task. – walkar Feb 18 '14 at 6:24
    
I'll check if Texmaker allows that. Thanks! To both you, and Uwe Ziegenhagen. – walkar Feb 18 '14 at 6:38
1  
Texmaker can definitely do find and replace, look under the Edit menu. See also tex.stackexchange.com/questions/67709/… – Torbjørn T. Feb 18 '14 at 7:06
4  
your human editors will thank you for this consideration. well, maybe they won't even know that you did it, but they surely won't curse you for not doing it. – barbara beeton Feb 18 '14 at 14:04

Globally replacing all instances of \mb{ with \mathbb{ should be feasible with just about every modern editor. No "regular" expressions involved in such an operation, as far as I can tell.

share|improve this answer
1  
Another one off the list, thanks – Johannes_B May 9 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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