2

Is it possible to place a matrix in a Section Heading?

This is my current attempt:

\section{Analyze the invertible $M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$ matrix by doing the following:}

I want it to read: enter image description here

Any help is appreciated as I am new.

3 Answers3

4

You can use a lrbox to create a box containing the math stuff and then use it in the argument of \section.

First of all, add

\newsavebox{\mybox}

in the preamble. Then embed the math stuff in the lrbox

\begin{lrbox}{\mybox}
$M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$
\end{lrbox}

and finally print the box inside the \section:

\section{Analyze the invertible \usebox{\mybox} matrix by doing the following:}

MWE:

\documentclass{article}
\newsavebox{\mybox}

\begin{document}

\begin{lrbox}{\mybox}
$M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$
\end{lrbox}

\section{Analyze the invertible \usebox{\mybox} matrix by doing the following:}

\end{document} 

enter image description here

This doesn't disturb the \tableofcontents but consider using the optional argument of \section to print something different in the ToC, if you are printing it.

karlkoeller
  • 124,410
2

With a lot of \protects for the toc ;-)

\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\begin{document}

\tableofcontents

% Protection for the math stuff written to toc
\section[{$M= \protect\left[\protect\begin{array}{rr}   2 & 6 \\   2 & 4 \protect\end{array}\protect\right]$}]{Analyze the invertible  matrix \protect{$M= \left[ \begin{array}{rr}
  2 & 6 \\
  2 & 4 
\end{array} \right]$}
 by doing the following:}

% protection for both heading and toc
\section{Analyse the matrix {$M= \protect\left[\protect\begin{array}{rr}   2 & 6 \\   2 & 4 \protect\end{array}\protect\right]$}
 by doing the following:}


\end{document}

enter image description here

2

An addition, using the environment "smallmatrix" may look better in a section title.

Sample output

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}
\newsavebox{\mybox}
\begin{document}
\begin{lrbox}{\mybox}
$M=\small[\begin{smallmatrix}a&b\\c&d\end{smallmatrix}\small]$
\end{lrbox}
\tableofcontents
\section{Analyze the invertible {\usebox{\mybox}} by doing the following}
\end{document}
Andrew Swann
  • 95,762
Secant
  • 31