# Embedding a matrix inside a subsection tag

I recently encountered a problem where the computer displays the following errors

Argument of \@sect has an extra }. [}}]
Paragraph ended before \@sect was complete.


when I ask it to run the following code

\subsection{{\setstretch{1.2}Show that $e^D = \begin{bmatrix} e^{d_1} & 0 & \ldots & 0 \\ 0 & e^{d_2} & \ldots & 0 \\ \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & \ldots & e^{d_n} \end{bmatrix}$
}}


What is wrong? I have the brackets matched, so why isn't it happy?

• there are lots of fragile commands there that would need \protect but that is a very weird title for a section, what is the body of the section? – David Carlisle Jun 25 '17 at 23:21
• A proof of the thing in the title. – D.R Jun 25 '17 at 23:23
• If you don't need this in the table of contents or heading use \subsection[simple title]{weird stuff} otherwise (at least) \setstretch, \begin \end are fragile and need \protect in a moving argument – David Carlisle Jun 25 '17 at 23:28
• I suspect \setstretch{1.2} here should be something like \renewcommand{arraystretch}{1.2}. I don't know if it is fragile, though. – Bernard Jun 26 '17 at 0:03