Latex showing "undefined control sequence" error when using cases inside align*

8,238

Please provide a MWE for the next time.

The following code should solve your problem:

\documentclass[12pt, fleqn]{scrreprt}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[scaled]{}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}

\begin{document}

\begin{align*}
    A\left(x\right)=
    \begin{cases} 1, &\textrm{if } x = 1 \\
        0, &\textrm{otherwise}
    \end{cases}
\end{align*}


\end{document}
Share:
8,238

Related videos on Youtube

user2565010
Author by

user2565010

Updated on February 28, 2020

Comments

  • user2565010
    user2565010 over 3 years

    I am trying to use LaTeX to run the following code:

    \begin{align*}
        A\left(x\right)&=
            \begin{cases}
                1, &\text{if } x \eq 1\\
                0, &\text{otherwise}
            \end{cases}
        \end{align*}
    

    I want it to show the multiple values A(x) can have, however I am getting two errors at the same line and saying the same thing.

     undefined control sequence <argument> ...begin {cases} 1, &\text {if } x \eq
    1\\ 0, &\text {otherwise} ...
    l.54 \end{align*}
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    

    Could anybody please tell me how do I make LaTeX display what I would like?

    • Steven B. Segletes
      Steven B. Segletes over 8 years
      Maybe I'm daft, but what is \eq? Perhaps =?
    • user2565010
      user2565010 over 8 years
      wow. I thought since <, >, <= and => were special characters, which were written like in bash for example, = made no exception. That was indeed the solution, to a one-symbol typo which produced two errors. thanks
    • Sigur
      Sigur over 8 years
      Or \neq. lol.
    • daleif
      daleif over 8 years
      also it you get a better semantics by using \text{if $x=1$} instead of just writing the textual comment in \text
    • Mico
      Mico over 8 years
      For a single unnumbered displayed equation, it's better to use equation* rather than align*.
    • Steven B. Segletes
      Steven B. Segletes over 8 years
      As an old FORTRAN user (in both senses of the word), I could immediately relate to the problem of slipping into \eq.
  • Sigur
    Sigur over 8 years
    Why are you using \textrm{}?
  • Mico
    Mico over 8 years
    Are the first five \usepackage statements necessary?