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.

In Lyx how do I find and replace words with latex code (ERT)?

share|improve this question
    
possible duplicate of Lyx customized view of command –  Hendrik Vogt Mar 16 '11 at 17:01
    
1) close lyx 2) open proper TeX IDE? But seriously, once you start hitting up against these limitations in LyX, it might be time to join the dark side... –  Seamus Mar 16 '11 at 17:07
    
@Seamus You might be right, before I give up I thought I'd see if there's a simple solution I'm missing. You think Lyx developers would implement that, it seems kind of essential to me. –  denilw Mar 16 '11 at 17:42
    
@Hendrik I don't seen how this question is related to that one. –  denilw Mar 16 '11 at 17:45
    
I'm trying to do a simple find and replace, but instead of replacing a word with another word I want to replace a word with ERT or a combination of letters and ERTs. –  denilw Mar 16 '11 at 17:46

2 Answers 2

up vote 3 down vote accepted

I don't think there is a way to do that in LyX 1.6, but in LyX 2.0, which is supposed to be released pretty soon, and which is currently available as a release candidate version, this is very easy with "Advanced search". You can pretty much search for any formatted text or even math, and replace them with anything else.

share|improve this answer
    
+1 Thank you for the response. Say I'm trying to replace the word DNA with the LaTeX code \gls{DNA} for it's glossary entry. I'm using the version 2 pre-release candidate and I can confirm this works. If I try and do the reverse though it does not work. –  denilw Mar 18 '11 at 16:31
    
It seems that you have to go the settings tab on the advanced search dialog, and uncheck "ignore format". –  Jan Hlavacek Mar 18 '11 at 19:22

You can do this with sed for Lyx 1.6 files. If you create a Lyx file in.lyx with the text:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Then run (Unix shell syntax, multiline command):

<in.lyx >out.lyx sed 's/voluptate/\ 
\begin_inset ERT\
status open\
\
\begin_layout Plain Layout\
\
voluptate\
\end_layout\
\
\end_inset\
/'

The file out.lyx will show in Lyx with "voluptate" in an ERT box.

share|improve this answer
    
+1 Great answer. Very useful. Thank you. –  denilw Apr 13 '11 at 16:52

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.