LaTeX forum ⇒ LyXProblem with Search and replace in math equations

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Posts: 3
Joined: Mon Mar 30, 2015 8:15 pm

Problem with Search and replace in math equations

Postby soszoe » Mon Mar 30, 2015 8:31 pm

I want to search and replace the string sn by \sn
inside math equations.
I can't find how to do that, trying different options I get
undesired results.

Now more details:

I have written an article using the special function sn
(Jacobi elliptic function). Example:
  1. \[ \frac{sn^2(x)}{1+a sn(x)} \]

Afterwards I wanted to use the right typography for mathematical
functions and use the new command \sn.
In the preamble I declared:


Then I wanted to replace every "sn" by "\sn". Example:
\[ \frac{\sn^2(x)}{1+a \sn(x)} \].

I'm not able to do this in any way.
Thanks a lot.


User avatar
Site Moderator
Posts: 4163
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Mar 30, 2015 9:24 pm

Hi and welcome,

since it is quite possible, that you also have the letters sn in normal text, or as well inside an equation, your only chance seems to be interactively change every occurence of the string.

I think the chance of looking out for non letter followed by sn followed by non letter might be unique and more easy to change. But that is something for experienced regular expressions guys. Sadly, i am not one of them.

You could ask on or Using sed or awk should get the task done, but this might be quite hard if you have no experience at all and you might be faster by doing manually.
If you decide to ask for help on regular expressions (please crosslink and share the solution with us) you might be faster if there is ever the need to do that again. Regular expressions are always helpful ;-)

On the other hand, this could have been prevented by some more preparation :-p
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Posts: 3
Joined: Mon Mar 30, 2015 8:15 pm

Postby soszoe » Tue Mar 31, 2015 4:46 pm

Hi Johannes_B, thank you for your reply.
I thought there was an easy way to do that in LyX because for me it should be a common action to search in equations and modified them automatically.
What I think I'm going to do is to edit the file with an external text editor and then search and replace the strings as normal text. I can't figure out why it can't be done inside LyX.
thank you again.

Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Postby scottkosty » Tue Mar 31, 2015 5:17 pm

Note that LyX's Advanced Find (ctrl + shift + f) can search within maths.

Posts: 3
Joined: Mon Mar 30, 2015 8:15 pm

Postby soszoe » Tue Mar 31, 2015 6:13 pm

Yes. I know, I have used it.
The problem is not searching but replacing. When I try to search and replace "sn" by "\sn" I get weird results as LyX doest not paste the plain string \sn straightforwardly.

Return to “LyX”

Who is online

Users browsing this forum: No registered users and 3 guests