Texmaker and TeXstudioSearch & replace query with two arguments?

Information and discussion about Texmaker, an integrated LaTeX environment for several platforms, and the related TeXstudio
Post Reply
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Search & replace query with two arguments?

Post by Montag »

[editor: TeXMakerX]

Hello,

I'd like to perform a search & replace query for a command named "\suli", which is defined as

Code: Select all

\newcommand{\suli}[2]{\sum\limits^{#1}_{#2}}
. A document of mine is filled with this command. What I would like to achieve, is this:

Code: Select all

\sum_{#1}^{#2}
, meaning the arguments would get switched and the \limits-command omitted. Is there a way to do this? :)
Last edited by Montag on Thu Sep 02, 2010 8:08 am, edited 2 times in total.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

benibela
Posts: 97
Joined: Thu Aug 09, 2007 8:13 pm

Search & replace query with two arguments?

Post by benibela »

Why not

Code: Select all

\renewcommand{\suli}[2]{\sum_{#1}^{#2}}
? That's the safest way.

Otherwise you can search for

Code: Select all

\\suli\{([^}]+)\}\{([^}]+)\}
And replace it with

Code: Select all

\sum_{\2}^{\1}
(if there are no nested latex commands in #1/2)
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Search & replace query with two arguments?

Post by Montag »

Hm, thank you for your reply, I appreciate it. :) If I understood correctly, something like

Code: Select all

\suli{n}{i=1}(x_{i}-\overline{x})(y_{i}-\overline{y})}
should be replaced with your query, right?
Well, it didn't work, neither with an enabled checkbox nor with a disabled checkbox for "Search for meta symbols". Did I do something wrong?
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
benibela
Posts: 97
Joined: Thu Aug 09, 2007 8:13 pm

Re: Search & replace query with two arguments?

Post by benibela »

Have you enabled "Regexp"?
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Search & replace query with two arguments?

Post by frabjous »

Last I checked, the standard version of Texmaker could not handle regular expressions in find/replace. TexmakerX can, however.
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Search & replace query with two arguments?

Post by Montag »

benibela wrote:Have you enabled "Regexp"?
Now I did. And it worked. Thank you. :)
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
Post Reply