
Ist es möglich, eine Matrix in eine Abschnittsüberschrift einzufügen?
Dies ist mein aktueller Versuch:
\section{Analyze the invertible $M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$ matrix by doing the following:}
Ich möchte, dass es lautet:
Da ich neu bin, bin ich für jede Hilfe dankbar.
Antwort1
Sie können ein verwenden, lrbox
um eine Box mit dem mathematischen Zeug zu erstellen und es dann im Argument von zu verwenden \section
.
Fügen Sie zunächst hinzu
\newsavebox{\mybox}
in der Präambel. Dann betten Sie den mathematischen Kram in dielrbox
\begin{lrbox}{\mybox}
$M= \left[ \begin{array}{rr}2 & 6 \\
2 & 4 \end{array} \right]$
\end{lrbox}
und drucken Sie abschließend das Feld im Inneren aus \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}
Dies stört nicht, \tableofcontents
aber ziehen Sie in Erwägung, das optionale Argument zu verwenden, um \section
etwas anderes im Inhaltsverzeichnis zu drucken, wenn Sie es drucken.
Antwort2
Mit ganz vielen \protect
s für die 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}
Antwort3
Eine Ergänzung: Die Verwendung der Umgebung „smallmatrix“ sieht in einem Abschnittstitel möglicherweise besser aus.
\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}