TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 have already finished writing my work and now I decided to change notation. How can I do it in preamble? More precisely I use $\mathcal{R}([a,b])$ in all my work and I would prefer to get $\mathcal{R}[a,b]$.

share|improve this question
Had you used something like \newcommand\myexp[3]{\mathcal{#1}([#2,#3])}, the only thing to do would be to delete the parentheses. – Gonzalo Medina Jul 30 '12 at 16:27
up vote 10 down vote accepted

You could redefine \mathcal to do the replacement on the fly but it would be fragile and make your tex fragments hard to use in any other context. Better to use a regular expression replace and just edit the source.

For example starting from a file reg.tex


then a sed command line such as

$ sed -e 's/\\mathcal{R}(\([^()]*\))/\\mathcal{R}\1/g' reg.tex

would output


with the round brackets gone.

sed is standard in some operating systems but similar regular expression edits could be made in any reasonable text editor.

share|improve this answer

Define a command:


and change all the instances of $\mathcal{R}([a,b])$ into $\myR{a}{b}$. It won't help you much this time, because you'll still have to manually (or semi-automatically, with regexp) the source. But when you change your mind and decide that $\mathcal{R}([a,b])$ was better after all, you'll have it easier.

I realize this is probably not the answer you were expecting, but I guess other solutions are going to be a headache (now and later).

share|improve this answer

Your Answer


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.