How to make LyX math macros available across documents?
Paul A. Rubin
parubin73 at gmail.com
Fri Aug 6 15:15:10 UTC 2021
On 8/6/21 5:52 AM, Tobias Hilbricht wrote:
> Dear readers of this list,
>
> in my worksheets in chemistry I have to write chemical formulas and
> physical quantities very often. But while that is very easy to do in
> LyX out of the box with chemical formulas due to the integration of
> mhchem and its macro \ce, I am still trying to achieve something
> similar for physical quantities with siunitx and its macro \qty.
>
> What I have so far is a working LyX math macro (in LyX Ctrl+M on
> \newcommand{\mqty}[2]{\qty{#1}{#1}}) which I can invoke with a keyboard
> shortcut (Alt+Q for "command-sequence math-insert \mqty; char-left;
> char-left").
>
> But I have to copy this custom LyX macro from document to document
> (siunitx loaded, of course). By contrast, I can invoke the macro \ce in
> math mode with a keyboard shortcut without further ado in every
> document and enjoy the immediate preview and avoid ERT.
>
> How is it possible to have custom macros available across documents in
> the same way?
>
> Thanks for helpful hints in advance!
>
> Yours
> Tobias
>
>
>
I can think of at least three possibilities.
* If you will use the custom code routinely, create a document
containing it and make that document your new default document
(Document > Settings ... > Save as Document Defaults.
* Create a document template that contains the custom code in its
preamble. You just create an otherwise empty document with your
preferred default settings and the custom code and save it in your
local templates document. When you want to use the custom code,
start your new document with File > New from Template ... and select
the correct template.
* Create a module (Customization manual, section 5.2.1) containing the
custom code, store it in your local layouts folder, and then
reconfigure LyX so that LyX can find it. Thereafter, you can add it
to any document using Document > Settings ... > Modules.
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-users/attachments/20210806/a904993f/attachment.html>
More information about the lyx-users
mailing list