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?

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.