Putting a matrix inside of caption gives \caption has an extra }
\begin{matrix}
and \end{matrix}
are fragile commands that do not survive the writing process being connected to \caption
-- the content is written to the .aux
file and to the .lof
file later on with \@writefile
.
In order to prevent the fragility there, the commands \begin{matrix}
and \end{matrix}
have to be protected with \protect
, i.e. \protect\begin{matrix}
and \protect\end{matrix}
.
If the protection is not activated, \caption
prematurely encounters a }
which is not the ending bracket of its mandatory argument.
A better way is to apply the optional argument of \caption
and prevent the writing of math content to the .aux
and .lof
file, i.e. use the short
and the long caption
style.
However, if fragile content should be written in the short
caption argument, the protection must be enabled again.
Alternatively use robust commands.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{thmtools}
\usepackage{graphicx}
\setlength\parindent{0pt}
\usepackage[linesnumbered,ruled]{algorithm2e}
\usepackage{hyperref}
\usepackage{caption}
\usepackage{cleveref}
\begin{document}
\listoffigures
\section{Introduction}
\begin{figure}[ht]
\centering
\includegraphics{ente}
\caption{$x^\star =\protect\begin{bmatrix} \alpha, \beta, \gamma \protect\end{bmatrix}$}
\caption[Foo content]{$x^\star =\begin{bmatrix} \alpha, \beta, \gamma \end{bmatrix}$}
\label{fig:just_picture_of_cute_cat}
\end{figure}
\end{document}
With a cat :-P
Add \protect
on entering and leaving the environment:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{graphicx}
\setlength\parindent{0pt}
\usepackage{caption}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[scale=0.5]{vent_cat}
\caption{$x^\star =\protect\begin{bmatrix} \alpha, \beta, \gamma \protect\end{bmatrix}$}
\label{fig:just_picture_of_cute_cat}
\end{figure}
\end{document}