Take the 2-minute tour ×
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.

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
1  
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
add comment

2 Answers

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

$\mathcal{R}([a,b])$ 

then a sed command line such as

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

would output

$\mathcal{R}[a,b]$ 

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
add comment

Define a command:

\newcommand{\myR}[2]{\mathcal{R}[#1,#2]}

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
add comment

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.