%3D%5Cbegin%7Bcases%7D1%2C%20%26%7Cx%7C%20%5Cle%201%2C%5C%5C%200%2C%20%26%7Cx%7C%3E1.%20%5Cend%7Bcases%7D%24%20%E3%82%92%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%81%AB%E9%85%8D%E7%BD%AE%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%3F.png)
\documentclass[18pt,a4paper]{article}
...
\tableofcontents
...
\subsection{$f(x)=\begin{cases}1, &|x| \le 1,\\ 0, &|x|>1. \end{cases}$}
コンパイルすると、TeXstudio でエラーが発生します:
「\endcsname が挿入されていません。\end{cases}$ }」
数式をコンテンツに組み込むにはどうすればいいですか?
答え1
\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}