# How to insert newline in Lyx-macro?

I want to create a Lyx-macro that takes two inputs in math and stacks them above each other, upper and lower part of the same size. Below is the definition in Latex and its desired use. How can I define the command in Lyx as macro?

I do not know how to insert a \\ in the macro environment. Ctrl-Enter is disabled and Enter leaves the macro environment and typing \\ gives me \backslash. When I edit the .lyx file and add the \\ directly I get the desired result. But I don't know how input this in the lyx-editor.

\documentclass{standalone}
\usepackage{amsmath}
\newcommand{\vchop}[2]{\begin{gathered}#1 \\ #2 \end{gathered}}
\newcommand{\vchopp}[3]{\begin{gathered}#1 \\ #2 \\ #3\end{gathered}}
\begin{document}
$\vchop{1}{5};P$
\end{document}


Edit: Copying a gathered environment with the desired number of rows from a math-expression not in a macro into the macro works. But this is not optimal.

• I see your problem. It also seems to work if you write out \begin{gathered}#1 \\ #2 \end{gathered} in non-math mode, then paste it into the TeX field, or highlight a non-math line newcommand... and then choose Insert > Inline formula. A keybaord shortcut with function command-sequence math-insert \begin{gathered}; newline-insert newline will also work. – Rasmus May 8 '14 at 13:26