6

I'm writing something up where I want to be explicit about some elementary operations I'm performing. I have an arrow between matrices with some text above the arrow showing what I'm doing. The text above the arrow is quite long, is it possible to cause a line break of some sort in stackrel?

My code is the following:

\stackrel{R2:= R2-2R1,\ R3:= R3+2R1}{\longrightarrow}
  • Could you show how you intend to use it? Perhaps even including some mock-up of the expected output. – Werner Jan 31 '14 at 4:27
6

\substack or subarray are your friends.

I suggest two commands, one for centered alignment of the elementary operation denotations, one for left alignment, that you might prefer.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\elem}[1]{% elementary operations
  \xrightarrow{\substack{#1}}%
}

\newcommand{\lelem}[1]{% elementary operations (left alignment)
  \xrightarrow{\begin{subarray}{l}#1\end{subarray}}%
}

\begin{document}

\[
\elem{R2:= R2-2R1,\\ R3:= R3+2R1}\quad
\lelem{R2:= R2-2R1,\\ R3:= R3+2R1}
\]

\end{document}

enter image description here

There's no need to have multiple lines: \elem{R2:=R2-2R1} would work seamlessly.

4

What is wrong with substack?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  $\stackrel{\substack{R2:= R2-2R1,\\ R3:= R3+2R1}}{\longrightarrow}$
\end{document}

enter image description here

  • The first is of course wrong. – egreg Jan 31 '14 at 11:18
  • The vertical alignment will be completely wrong. – egreg Jan 31 '14 at 22:19
3

Perhaps a combination of \overset and \shortstack?

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\overset{\shortstack{$\scriptstyle R2:= R2-2R1$,\\ $\scriptstyle R3:= R3+2R1$}}{\longrightarrow}\quad
\overset{\shortstack[l]{$\scriptstyle R2:= R2-2R1$,\\ $\scriptstyle R3:= R3+2R1$}}{\longrightarrow}
 \]

\end{document}

enter image description here

The optional argument for \shortstack allows you to control the alignment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.