# Why does align come out of math mode? [duplicate]

The following:

\begin{align*}
F
=
{}&a^2+b^2=c^2
\notag\\\rm{subject~to} & \;
5+1=6 \;\rm{ and }\;  a+b=c.
\end{align*}


produces a+b=c that isn't in math mode. Why?

• Because \rm is a switch and not a command taking an argument. Use \text{...} instead. – Henri Menke Sep 21 '17 at 23:24
• Because you've used \rm which (1) shouldn't be used in LaTeX since it was made obsolete a few decades ago and (2) does not take an argument, since it is a switch. It switches to the default serif family until the end of the current group or the end of the document. You haven't provided a complete example, but this has zilch to do with align and everything to do with abuse of font macros. – cfr Sep 21 '17 at 23:24
• Write \text{subject to and \text{ and }. Don't use \rm. – Mico Sep 21 '17 at 23:25
• another potential duplicatea; Difference between \xx{} and \mathxx{}? – barbara beeton Sep 22 '17 at 0:22

The issue with the incorrect -- it should be {\rm ...}, not \rm{...} -- and inappropriate -- \rm is badly deprecated; use \text{...} -- usage of \rm would appear to be just severe of several problems contained in the code.

• No purposeful aligning appears to be going on across the two rows. Hence, use a gather* environment, not an align* environment.

• Don't use \notag: there's simply no point doing so in either a gather* or an align* environment.

• Place the entire second row in the argument of a \text directive, and use inline math mode for the two formulas contained in the second row.

(Note that I'm note passing judgment on the actual mathematics -- that's not really the subject of this posting, is it?)

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*} % not "align*"
F = a^2+b^2=c^2 \\
\text{subject to $5+1=6$ and $a+b=c$.}
\end{gather*}
\end{document}

• Thanks - this fixed it! (The math was obviously fake garbage, and the align*, \notag, and lack of & were hold-overs from gutting out the actual equations that I'm using.) – rhombidodecahedron Sep 22 '17 at 7:55

\rm in curly bracket

        \documentclass[12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
F
=
{}&a^2+b^2=c^2
\\{\rm subject~to} & \;
5+1=6 \;{\rm and }\;  a+b=c.
\end{align*}
\end{document}

• \rm has been deprecated for more than 20 years. – egreg Sep 21 '17 at 23:27
• That's a bad answer. -1 – Henri Menke Sep 21 '17 at 23:29