2

I just created a new command that loads in the preamble: \newcommand{\e}{\epsilon}, and when i type \e in math mode, i don't see the epsilon in the editor, but it comes out as the epsilon that I want when i compile the file.

in the lyx editor:

enter image description here

But in the compiled result:

enter image description here

Is there a way to have it show the preambled commands in the lyx editor? If I just type \epsilon it does show the epsilon in the lyx editor.

thanks!

3
  • 1
    LyX can represent a subset of math symbols that ca be typed as commands, but is not really a TeX interpreter, it cannot understand the meaning any custom command. That is, \e is only traslated to \epsilon during the compilation (i.e., in the .tex to .pdf step) that is out of the LyX control.
    – Fran
    Oct 22, 2021 at 13:14
  • Welcome to tex.se, doximanman! Nice first question. It is well written and you took the time to make and post screenshots. -> +1
    – scottkosty
    Oct 22, 2021 at 16:23
  • It's worth noting that Alt+m g e will also get you the greek 'e' in math mode.
    – Al.G.
    Nov 5, 2021 at 19:00

1 Answer 1

1

As Fran mentioned in the comments, you need to teach LyX about your new command since LyX does not parse (i.e., understand) your custom LaTeX preamble. Remove the command from the preamble and do the following in the LyX document:

  1. Insert > Math > Macro.
  2. Press 'e' (this will replace "newmacroname" with "e").
  3. In the "TeX" box, put "\epsilon".
  4. You do not need to put anything in the LyX box since you want the LyX box to be the same as the TeX box in this case.

Now in math mode, type "\e" and then space. That should show an epsilon in the LyX display.

For more information, see Help > Math. It's long and dry, but worth a study if you plan to use LyX for a while.

2
  • But I'd need to do this every time I open a new document. Is there a way to make it so that when i click "new document" it will have those commands by default? Because from what I understand I'd have to either use a template and remember that I can only use "save us" initially before using "save" because it would change my template, or I'd have to add this macro every time I open a new document, which seems very tedious.
    – doximanman
    Nov 11, 2021 at 14:13
  • I'm not sure, but I don't think that's possible. What I do is to keep macros in one file, and then I "include" that file in other files. Indeed that does take a few clicks and you do need to remember to do that when you start a new file. I'm not sure there's a way to skip those steps. Having everything in one centralized file is nice though.
    – scottkosty
    Nov 11, 2021 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.