4

How can I use a cases environment inside \section or \subsection directives, like this:

\section{$y(t) = \begin{cases} case1 \\ case  \end{cases}$}

With pdflatex I get:

Use of \begin doesn't match its definition. ...begin{cases} case1 \ case \end{cases}$}

...

  • 7
    that's a very weird heading!!!!, but you could use \section[something reasonable for the page head]{$.....$} – David Carlisle Aug 9 '17 at 13:13
  • 4
    \protect\begin and \protect\end maybe? – egreg Aug 9 '17 at 13:18
5

You may achieve your typesetting objective using either a cases or an array environment; the latter will be spaced a bit more tightly. The trick, as pointed out by @egreg in a comment, is to \protect the \begin and \end directives.

enter image description here

\documentclass{article} 
\usepackage{amsmath} % for "cases" env.

\begin{document}
\tableofcontents
\medskip\hrule

\section{$y_t=\left\{ \protect\begin{array}{@{}c@{}} a_1 \\ a_2
              \protect\end{array} \right.$}

\section{$y_t=\protect\begin{cases} a_1 \\ a_2 
              \protect\end{cases}$}
\end{document}

If the math material in the section header has to be typeset in bold, just insert the directive \boldmath immediately before $y_t=.

4

enter image description here

de gustibus non est disputandum

\documentclass{article}

\usepackage{amsmath}


\newsavebox\hmm
\savebox{\hmm}{$y(t) = \begin{cases} case1 \\ case  \end{cases}$}

\begin{document}


\section[something reasonable for the page head]{\usebox{\hmm}}


\end{document}

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.