Equation numbering gone wrong

2,348

You cannot break lines in equation. Use a gathered environment within equation. The label will be typeset between the equation lines, unless you load amsmath with the tbtags option. If you want the label to appear on the last line, you can use the gather environment, and \notag on the first two lines:

\documentclass{article}
\usepackage{mathtools}
\numberwithin{equation}{section}

\begin{document}
\setcounter{section}{3}
\begin{equation}
  \begin{gathered}
    \frac{c_r(6\sigma+3)+4\sigma²(\sigma-2P_c+1)-2P_c+1}{(2\sigma+1)²} = 0 \\
    \Updownarrow \\
    P_c^* = \frac{4\sigma²+4\sigma+1+4\sigma³+6c_r\sigma+3c_r}{2(1+4σ)}
  \end{gathered}
\end{equation}

\begin{gather}
  \notag \frac{c_r(6\sigma+3)+4\sigma²(\sigma-2P_c+1)-2P_c+1}{(2\sigma+1)²} = 0 \\
  \notag \Updownarrow \\
  P_c^* = \frac{4\sigma²+4\sigma+1+4\sigma³+6c_r\sigma+3c_r}{2(1+4σ)}
  \label{3.7bis}
\end{gather}

\end{document} 

enter image description here

Share:
2,348

Related videos on Youtube

Saud
Author by

Saud

Updated on August 01, 2022

Comments

  • Saud
    Saud 12 days

    There are three issues that I would like to fix which are probably interlinked, but don't know how (have tried a couple of things):

    1) Force the equation numbering of equation 3.7 to move to the right-hand side of the the lower equation (underneath the updownarrow, so it looks like the numbering of equation 3.8. 2) Avoid compressing the size of the lower equation 3) Avoid italic font of equation 3.8

    This is my code:

    \documentclass[12pt,twoside]{book}
    \usepackage{amssymb}
    \usepackage{amsthm}
    \usepackage{amsmath}
    \begin{document}
    
        \begin{equation}
         \frac{c_r(6\sigma+3)+4\sigma^2(\sigma-2P_c+1)-2P_c+1}{(2\sigma+1)^2} = 0 \\
             \center\Updownarrow \\
         P_c^* = \frac{4\sigma^2+4\sigma+1+4\sigma^3+6c_r\sigma+3c_r}{2(1+4\sigma)}\center
        \label{3.7}
        \end{equation}
        \vspace{-3cm}
    
     The original paper produces the following result:
    
        \begin{equation}
         P_c^* = \frac{4\sigma^2+4\sigma+1}{2(1+4\sigma)}
        \label{3.8}
        \end{equation}
    
    \end{document}
    

    enter image description here

    • Admin
      Admin over 6 years
      Please post the a working document, not just fragments
    • David Carlisle
      David Carlisle over 6 years
      you must have had multiple errors from that fragment? you can not use \\ or \center in equation
    • Saud
      Saud over 6 years
      @ChristianHupfer: Done.
    • Saud
      Saud over 6 years
      @DavidCarlisle: Yes, I do get three errors in total. For some reason, I can't see the explanations on them when I hover the mouse over.
    • Admin
      Admin over 6 years
      Using \label{3.7} is not really recommended. Please the alignat environment` for something like this
    • Saud
      Saud over 6 years
      @ChristianHupfer: What would you recommend instead?
    • David Carlisle
      David Carlisle over 6 years
      tex does not attempt to make sensible typeset output after an error, it just recovers enough to process the document to check for more errors. you can never use \center in math mode, for multi-line math display do not use equation use an environment from amsmath
    • Admin
      Admin over 6 years
      @Saud: Something easy to remember. What's the purpose of \labels if you name them like the equation number (which can change, most likely). Use \label{myimportantresult} or something like this
    • barbara beeton
      barbara beeton over 6 years
      you possibly want to try using the gathered environment inside the equation numbered 3.7; that will allow you to separate lines by \\ and center all the lines with only a single equation number. as @DavidCarlisle says, \\ is not allowed inside equation; that is meant for either one-line displays, or displays that have a grouping environment that treats them as a unit.
    • Saud
      Saud over 6 years
      @barbarabeeton: Haven't really used the gathered environment before, but after just having read about it makes sense.