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.

When we define new macros in LyX, can we still have instant preview for them?

For example, I defined a new command \abc, but when I put \abc in the math inset, it does not have instant preview. Though if I compile to a DVI, it's there in DVI.

Thank you.

share|improve this question
    
Welcome newuser! Could you fill out your question a bit more? "Instant preview" sounds a bit like <a href="tex.stackexchange.com/questions/tagged/…; but not sure in the context of macros. What is it you want to do? If you're asking for a feature to be added to LyX, though, you should <a href="lyx.org/trac/wiki/BugTrackerHome">contact the LyX developers</a> –  Matthew Leingang Oct 27 '10 at 19:01
    
@Matthew. By instant preview, I mean Tools->Preferences->Look&Feel->Display->Instant Preview. It's in the math inset. My problem is that, for example, I define a new command \abc, but when I put \abc in the math inset, it does not have instant preview. Though if I complie to a DVI, it's there in DVI. –  newuser Oct 27 '10 at 20:11
    
Hm, that's strange, it works for me. Can you give us more details? How exactly do you define \abc. Do you get instant preview if you do not use user defined commands? –  Jan Hlavacek Oct 27 '10 at 22:25
    
Hi, I get instant preview with ordinarty commands. And for example, I define $\newcommand{\abc}{A}$, then I put \abc in math inset, it does not show anything –  newuser Oct 28 '10 at 3:06
    
@newuser You really should not define commands in the middle of your document this way. LyX has no way of knowing you defined them, and cannot use them when generating the preview. Either define all your commands in the document preamble, or use "insert->math->macro" to define new commands using LyX math macros. Look at the "Math" section of LyX help menu for more details. –  Jan Hlavacek Oct 28 '10 at 16:50

1 Answer 1

Lyx is not WYSIWYG, because it does not make much effort to ensure that what it displays matches how it will be rendered as DVI or PDF. In particular, it will render Tex code blocks as source in the Lyx editing window, and compile it normally using Latex when generating DVI/PDF.

Lyx does not keep track of definitions made in Tex code blocks or in the preamble. If you want these to render in formulae, you have to define a layout, which isn't really for beginners.

share|improve this answer
    
LyX does seem to be keeping track of the definitions made in the preamble. You can also use math macros (Insert -> Math -> Macro), LyX does keep track of those. –  Jan Hlavacek Oct 28 '10 at 16:57
    
@Jan: Lyx assembles a Latex text from its own representation, but the contents of the preamble and Tex code block are completely uninterpreted. If one Tex block contains a \newcommand definition, Lyx won't know that it is related to a macro in another Tex block. Lyx can't do "instant preview" with them. –  Charles Stewart Nov 9 '10 at 16:55
    
@Charles: That's strange, when I test this, macros defined in the preamble do seem to be recognized in the preview. Also, it does not seem like it would be difficult for LyX to use the preamble in instant preview, and it would, in my opinion, be quite desirable to do that, since in preamble, you can load packages unsupported by LyX, change fonts, etc, and LyX really should take these into account when generating previews. And, at least on my computer, it does. –  Jan Hlavacek Nov 9 '10 at 19:12
    
@Jan: I've tried this out: with \newcommand{\five}{5} in either the preamble or a Tex block, the control sequence \five renders as whitespace. What do you mean by "macros defined in the preamble do seem to be recognized in the preview"? –  Charles Stewart Nov 9 '10 at 21:17
    
@Charles: here, when I put it in the preamble (Document->Settings...->LaTeX Preamble), it renders fine in a preview. If I include it in a ERT, it doesn't. Which is exactly what I would expect. My LyX version is 1.6.7. –  Jan Hlavacek Nov 9 '10 at 23:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.