0

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?

6
  • 1
    Maybe I'm daft, but what is \eq? Perhaps =? Feb 27, 2015 at 19:09
  • 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 Feb 27, 2015 at 19:13
  • Or \neq. lol.
    – Sigur
    Feb 27, 2015 at 19:14
  • 1
    also it you get a better semantics by using \text{if $x=1$} instead of just writing the textual comment in \text
    – daleif
    Feb 27, 2015 at 19:33
  • 2
    As an old FORTRAN user (in both senses of the word), I could immediately relate to the problem of slipping into \eq. Feb 27, 2015 at 20:09

1 Answer 1

1

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}
2
  • 2
    Why are you using \textrm{}?
    – Sigur
    Feb 27, 2015 at 19:38
  • 1
    Are the first five \usepackage statements necessary?
    – Mico
    Feb 27, 2015 at 19:45

You must log in to answer this question.

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