On Sat, Dec 31, 2022 at 10:32 PM tush via lyx-users <lyx-users@lists.lyx.org>
wrote:

> I created a style in my local layout that has "LatexType    Command".
> Is it possible to allow the user to insert multiple lines of text inside
> this command?
> Something like the option MultiPar   1 (which is good only for InsetLayout
> Flex, not for Style.)
>
> What I want is to get the following Latex code:
>
> \mycommand{Lorem ipsum
> 〈¶〉
> dolor
> 〈¶〉
> sit amet}
>
>
Hello ehud,

I don't know if it can be done in lyx, but i can suggest a workaround for
that (of course it is only
valid if your command is long in the first place).

You can set your style to be of "Latex Type    Environment" and create an
environment
that passes its body to \mycommand.

To do that, add to your style definition the following:

LatexName    myenv
Preamble
\newcommand\mycommand[1]{<definition of your command>}
\usepackage{environ}
\NewEnviron{myenv}{\mycommand{\BODY}}
EndPreamble

Note that with some commands it wont work due expansion order of \BODY,
so you might need to write

LatexName    myenv
Preamble
\newcommand\mycommand[1]{<definition of your command>}
\usepackage{environ}
\NewEnviron{myenv}{\expandafter\mycommand\expandafter{\BODY}}
EndPreamble

instead.

Hope it helps,
Udi

> lyx-users mailing list
> lyx-users@lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-users
>
-- 
lyx-users mailing list
lyx-users@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to