0
\documentclass[18pt,a4paper]{article}

...


\tableofcontents

...

\subsection{$f(x)=\begin{cases}1, &|x| \le 1,\\ 0, &|x|>1. \end{cases}$}

I compile it, TeXstudio gives me an error:

"Missing \endcsname inserted. \end{cases}$ }"

How to put the formula into content?

3
  • 7
    Do you really want to use a relatively big formula as section header?
    – campa
    Commented Aug 6, 2019 at 14:04
  • 1
    Don't do this. Rather give names to your cases.
    – Zarko
    Commented Aug 6, 2019 at 14:28
  • thank everyone ,I won't do it. Commented Aug 6, 2019 at 14:45

1 Answer 1

4
\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

\tableofcontents

\section{$f(x) = \protect\begin{cases} 2 & \vert x \vert < 3 \\ -5 & \vert x \vert > 4 \protect\end{cases}$}

\subsection{$f(x) = \protect\begin{cases} 1 & \vert x \vert < 1 \\ 0 & \vert x \vert > 1 \protect\end{cases}$}


\end{document}

enter image description here

1
  • Better \lvert...\rvert than \vert...\vert.
    – egreg
    Commented Aug 6, 2019 at 19:51

You must log in to answer this question.

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