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}
Related videos on Youtube
Author by
user2565010
Updated on February 28, 2020Comments
-
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 over 8 yearsMaybe I'm daft, but what is
\eq
? Perhaps=
? -
user2565010 over 8 yearswow. 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 over 8 yearsOr
\neq
. lol. -
daleif over 8 yearsalso it you get a better semantics by using
\text{if $x=1$}
instead of just writing the textual comment in\text
-
Mico over 8 yearsFor a single unnumbered displayed equation, it's better to use
equation*
rather thanalign*
. -
Steven B. Segletes over 8 yearsAs an old FORTRAN user (in both senses of the word), I could immediately relate to the problem of slipping into
\eq
.
-
-
Sigur over 8 yearsWhy are you using
\textrm{}
? -
Mico over 8 yearsAre the first five
\usepackage
statements necessary?