1

I have the following code:

\documentclass[]{article}
\usepackage{amsmath}

\begin{document}

\begin{gather*}
 \overset{-1*R_{4}\rightarrow R_{3} \\ -2*R_{4}\rightarrow R_{2} }{\rightarrow}
\end{gather*}

\end{document}

I get everything in one line over the arrow, but i need it to be in two lines as indicated by the line break \\.

Bernard
  • 271,350
dado
  • 13

2 Answers2

3

You can use the subarray environment. To make the arrow as long as the text you can use \xrightarrow.

Code:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

    With \verb|\rightarrow|:

    \[
        \overset{
            \begin{subarray}{l}
                -1*R_{4}\rightarrow R_{3}\\
                -2*R_{4}\rightarrow R_{2}
            \end{subarray}
        }{\rightarrow}
    \]

    With \verb|\xrightarrow|:

    \[
        \xrightarrow{
            \begin{subarray}{l}
                -1*R_{4}\rightarrow R_{3}\\
                -2*R_{4}\rightarrow R_{2}
            \end{subarray}
        }
    \]

\end{document}

Result:

enter image description here

dexteritas
  • 9,161
1

As you might have noticed from the answer above, spacing above the \rightarrow is an issue. My answer uses the substack command to achieve your stated aim of multiple lines, and a new macro found here for changing the space with overset.

Output:

enter image description here

MWE:

\documentclass[]{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\oset}[3][0ex]{%
    \mathrel{\mathop{#3}\limits^{
            \vbox to#1{\kern-2\ex@
                \hbox{$\scriptstyle#2$}\vss}}}}
\makeatother

\begin{document}

    \begin{gather*}
     \oset[3ex]{\substack{-1*R_{4}\rightarrow R_{3} \\ -2*R_{4}\rightarrow R_{2} }}{\rightarrow}
    \end{gather*}

\end{document}
Thev
  • 1,568