0

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?

4
  • 2
    Because \rm is a switch and not a command taking an argument. Use \text{...} instead. Sep 21, 2017 at 23:24
  • 2
    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, 2017 at 23:24
  • 1
    Write \text{subject to and \text{ and }. Don't use \rm.
    – Mico
    Sep 21, 2017 at 23:25
  • another potential duplicatea; Difference between \xx{} and \mathxx{}? Sep 22, 2017 at 0:22

2 Answers 2

3

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}
1
  • 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.) Sep 22, 2017 at 7:55
-1

\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}
2
  • 3
    \rm has been deprecated for more than 20 years.
    – egreg
    Sep 21, 2017 at 23:27
  • 2
    That's a bad answer. -1 Sep 21, 2017 at 23:29

Not the answer you're looking for? Browse other questions tagged .