I was trying to insert matrix into a \subsection{}:
\subsection{Suppose $X= \begin{array}{cc}
1 & 2 \\
3 & 4
\end{array}$}
This gives me an error:
! TeX capacity exceeded, sorry [input stack size=5000].
What is wrong here? Thanks!
I was trying to insert matrix into a \subsection{}:
\subsection{Suppose $X= \begin{array}{cc}
1 & 2 \\
3 & 4
\end{array}$}
This gives me an error:
! TeX capacity exceeded, sorry [input stack size=5000].
What is wrong here? Thanks!
If you need the matrix to show up in the table of contents, as well, here is one technique:
\documentclass{article}
\usepackage{tabstackengine}
\setstacktabbedgap{1ex}
\savestack{\mathexpr}{$X= \bracketMatrixstack{1 & 2 \\3 & 4}$}
\begin{document}
\tableofcontents
\section{Main Topic}
\subsection{Suppose \mathexpr}
\section{Next Topic}
\end{document}

I guess you want smallmatrix rather than array. But you can also use the full size version, if you really want.
The key is that \begin, \end and \\ are fragile so they need \protect in front of them when in a moving argument (section title or caption).
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\subsection{Suppose $X=\left[\protect\begin{smallmatrix}
1 & 2 \protect\\
3 & 4
\protect\end{smallmatrix}\right]$}
\subsection{Suppose $X=\protect\begin{bmatrix}
1 & 2 \protect\\
3 & 4
\protect\end{bmatrix}$}
\end{document}

\subsection[]{Suppose $X...It compiles for me. Note[]which is supposed to hold the short content. – Sep 30 '14 at 15:44amsmath\substack-command in section title – Werner Sep 30 '14 at 15:48