How can I use my defined commands in LyX? I have seen that this can be done in math mode but I have found no way to do it globally.
1 Answer
The most fundamental way you can include \newcommand
s you have in your Document > Settings... > LaTeX Preamble is to use an ERT (Insert > TeX Code or Ctrl+L):
With you preamble containing (say)
\newcommand{\quadratic}{ax^2 + bx + c}
the output resembles
Within math mode (Insert > Math), typing backslash \
automatically initiates an ERT.
-
-
@Adam: This works generally, yes. In math mode the use of
\
automatically assumes an ERT. Outside of math mode, a\
is converted to\textbackslash
.– Werner ♦Nov 1, 2016 at 18:57 -
Thank you! One last thing...Is there live preview for defined commands as when you write equations?– AdamNov 1, 2016 at 18:58
-
1@Adam: Not natively, as you can technically have arbitrary content within a
\newcommand
, which doesn't have an HTML visual equivalent within the LyX display. You'll have to view the output - Ctrl+R - to see the rendered interpretation.– Werner ♦Nov 1, 2016 at 19:00 -
@Adam you might be interested in LyX's "math macros". See Help > Math and go to the section User-defined Commands > Math Macros. Nov 1, 2016 at 23:07
\newcommand
s that you have in your LaTeX preamble?