1

I'm trying to write a simple case equation with the following code:

\begin{align}
\begin{equation}
  S_{new}=
  \begin{cases}
    max(S_{new}) &\text{if $S_{CTA} > 70 \parallel S_{DCE-CT} < \tau_{flow}$}\\
    0.2\log({S_{CTA}/80}) + 0.8\log({\tau_{flow}/S_{DCE-CT}}) &\text{else}
  \end{cases}
\end{equation}
\end{align}

Which outputs this incorrect number

The equation number should be (1) not (2), how do I fix this?

3
  • 1
    Welcome to TeX.SE! Can you please make your code snippet be compilable, then we do not have to guess what you are doing ....
    – Mensch
    Oct 8, 2021 at 21:24
  • 4
    You cannot nest equation within align; remove the outer align environment. You should be getting errors from that code. Never ignore TeX errors; the resulting output is in general garbage, as in this case.
    – campa
    Oct 8, 2021 at 21:46
  • 1
    It's almost certainly because of the align outside the equation.
    – Don Hosek
    Oct 8, 2021 at 22:05

1 Answer 1

4

I add two possibilities. The second is the best because the geometry package provides uniformity for the sheet margins. In addition I have tried to improve some code anomalies as highlighted in the comments.

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath,amssymb}
\begin{document}

\begin{equation}
  S_{\textup{new}}=
  \begin{cases}
    \max(S_{\textup{new}}) \quad \text{if $S_{CTA} > 70 \parallel S_{DCE-CT} < \tau_{\textup{flow}}$}\\
    0.2\log({S_{CTA}/80}) + 0.8\log({\tau_{\textup{flow}}/S_{DCE-CT}}) &\text{else}
  \end{cases}
\end{equation}

\begin{equation}
  S_{\textup{new}}=
  \begin{cases}
    \max(S_{\textup{new}}) & \text{if $S_{CTA} > 70 \parallel S_{DCE-CT} < \tau_{\textup{flow}}$}\\
    0.2\log({S_{CTA}/80}) + 0.8\log({\tau_{\textup{flow}}/S_{DCE-CT}}) &\text{else}
  \end{cases}
\end{equation}
\end{document}

enter image description here

An addendum after the comment of @Zarko using \usepackage{cases} with the enviroment numcases.

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath,amssymb}
\usepackage{cases}
\begin{document}

\begin{numcases} 
  {S_{\textup{new}}=}
    \max(S_{\textup{new}}) & \text{if $S_{CTA} > 70 \parallel S_{DCE-CT} < \tau_{\text{flow}}$}\\
    0.2\log({S_{CTA}/80}) + 0.8\log({\tau_{\textup{flow}}/S_{DCE-CT}}) &\text{else}
    \end{numcases} 
\end{document}

enter image description here

8
  • If I correctly understand OP, (s)he like to have numbered each equation in cases (as is for example provided by numcases environment defined in the cases package package.
    – Zarko
    Oct 8, 2021 at 22:18
  • @Zarko You know that I not understand well the English language. :-) With a lot of sincerity I have not understood that the user want numbered every equation. :-(
    – Sebastiano
    Oct 8, 2021 at 22:19
  • Oh, I may be wrong. Code fragment is erroneous and question is unclear. It seems that both have fogy crystal balls :-). I'm sure that your English is slightly better than mine ;-). Anyway, I give +1 :-)
    – Zarko
    Oct 8, 2021 at 22:33
  • 1
    Thanks to everyone who answered. As some commenters mentioned, the {align} outside of {equation} was the issue. I accepted Sebastiano's answer since it both solves the issue but also looks better than what I originally wanted (Thanks lol).
    – agw3333
    Oct 9, 2021 at 0:11
  • 2
    Again, \text should never be used for upright text in subscripts (or similar), \text does not do what you think. Please use \mathrm or even \textup in those subscripts instead.
    – daleif
    Oct 9, 2021 at 4:49

You must log in to answer this question.

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