LaTeX forum ⇒ Texmaker and TeXstudioSearch & replace query with two arguments? Topic is solved

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

Search & replace query with two arguments?

Postby Montag » Wed Sep 01, 2010 10:51 am

[editor: TeXMakerX]

Hello,

I'd like to perform a search & replace query for a command named "\suli", which is defined as
  1. \newcommand{\suli}[2]{\sum\limits^{#1}_{#2}}
. A document of mine is filled with this command. What I would like to achieve, is this:
  1. \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

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

Postby benibela » Wed Sep 01, 2010 4:34 pm

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

Otherwise you can search for
  1. \\suli\{([^}]+)\}\{([^}]+)\}

And replace it with
  1. \sum_{\2}^{\1}

(if there are no nested latex commands in #1/2)

Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

Postby Montag » Wed Sep 01, 2010 7:01 pm

Hm, thank you for your reply, I appreciate it. :) If I understood correctly, something like
  1. \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

Postby benibela » Wed Sep 01, 2010 7:52 pm

Have you enabled "Regexp"?

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Postby frabjous » Wed Sep 01, 2010 8:45 pm

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

Postby Montag » Thu Sep 02, 2010 8:07 am

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


Return to “Texmaker and TeXstudio”

Who is online

Users browsing this forum: No registered users and 4 guests