0

I'm trying to do an easy system, but I received a lot of errors.

\[ f(x) =
\begin{cases}
x  & \quad \text{if x > 0\\
0  & \quad \text{else}
\end{cases}
\]

Probably I'm doing something wrong and I receive a lot of errors, in particular for the use of &. Can anyone help me please?

2
  • 1
    A single mistake can generate a lot of errors. Dunno why but as a programmer I face this all the time.
    – Arnaud
    Commented Jan 25, 2020 at 12:38
  • 1
    Please extend your code fragment to complete small document, which we can test as it is. From code fragment follows, that there is missing } after \text{... .This error is not related to LuaTeX.
    – Zarko
    Commented Jan 25, 2020 at 12:47

1 Answer 1

2

You simply miss the closing brace } at the end of \text{if. Afterwards, you can quit the textmode before x > 0 to typeset x in math mode.

You have finally :

\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
    \[ f(x) =
    \begin{cases}
    x  & \quad \text{if } x > 0\\
        0  & \quad \text{else}
        \end{cases}
        \]
\end{document}

with the corresponding output : enter image description here

1
  • the missing brace it's because I did a bad copy of the code, but the package amsmath resolve it, thanks!
    – Simo
    Commented Jan 25, 2020 at 14:20

You must log in to answer this question.

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