
Можно ли разместить матрицу в заголовке раздела?
Вот моя текущая попытка:
\section{Analyze the invertible $M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$ matrix by doing the following:}
Я хочу, чтобы это было написано так:
Любая помощь будет оценена по достоинству, так как я новичок.
решение1
Вы можете использовать a lrbox
для создания поля, содержащего математические данные, а затем использовать его в аргументе \section
.
Прежде всего, добавьте
\newsavebox{\mybox}
в преамбуле. Затем вставьте математические выкладки вlrbox
\begin{lrbox}{\mybox}
$M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$
\end{lrbox}
и наконец распечатайте поле внутри \section
:
\section{Analyze the invertible \usebox{\mybox} matrix by doing the following:}
МВЭ:
\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}
Это не влияет на , \tableofcontents
но рассмотрите возможность использования необязательного аргумента , чтобы \section
напечатать что-то другое в оглавлении, если вы его печатаете.
решение2
С большим количеством \protect
букв s для 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}
решение3
Кроме того, использование окружения «smallmatrix» может выглядеть лучше в заголовке раздела.
\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}