Using LaTeX, I am trying to add a caption to my matrix, something like this;
I don't want to add it as a table and when I add a caption it gives an error, \caption outside float
, probably because I am trying to add a caption inside equation tags. Is there an easy way to accomplish this. Thank you.
Edit: Apologies for not giving the code. This is the code for the matrix
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{bmatrix}
\cos\theta_i & -\sin\theta_i \cdot \cos\alpha_i & \sin\theta_i \cdot \cos\alpha_i & ln \cdot \cos\theta_i \\
\sin\theta_i & \cos\theta_i \cdot \cos\alpha_i & -\cos\theta_i \cdot \sin\alpha_i & ln \cdot sin\theta_i \\
0 & \sin\theta_i \cdot \cos\alpha_i & \cos\alpha_i & d_i \\
0 & 0 & 0 & 1
\end{bmatrix}
\end{equation}
\captionof{Matrix 3.1: }{HTM of Manipulator}
\end{document}
It does give the error undefined control sequence
You could use the \captionof
macro from the caption
package to add captions outside of floats:
\documentclass{article}
\usepackage{amsmath}
\usepackage{caption}
\DeclareCaptionType[within=section]{mat}[Matrix]
\begin{document}
\section{Section}
\begin{equation}
\begin{bmatrix}
\cos\theta_i & -\sin\theta_i \cdot \cos\alpha_i & \sin\theta_i \cdot \cos\alpha_i & ln \cdot \cos\theta_i \\
\sin\theta_i & \cos\theta_i \cdot \cos\alpha_i & -\cos\theta_i \cdot \sin\alpha_i & ln \cdot sin\theta_i \\
0 & \sin\theta_i \cdot \cos\alpha_i & \cos\alpha_i & d_i \\
0 & 0 & 0 & 1
\end{bmatrix}
\end{equation}
\captionof{mat}{HTM of Manipulator}
\end{document}