# How to centre a matrix?

In order to make your code snippets compilable and in an attempt to focus on what's relevant for the issue at hand, I've come up with the following minimum working example (MWE):

\documentclass{article}
\usepackage{amsthm,amsmath,amssymb}
\newtheorem*{definition}{\sc{Definition}}
\begin{document}
\begin{definition}
Determinant of a $3 * 3$ grid. For a $3 * 3$ grid, given as

\vspace{5mm} %5mm vertical space

\begin{bmatrix}

a & b & c \\
d & e & f \\
g & h & i \\
\end {bmatrix}\\

\vspace{5mm} %5mm vertical space
The determinant is: $a (ei-hf) - b (di -gf) + c (dh - ge)$
\end{definition}
\end{document}


This MWE generates the following trail of messages in the log file:

 ! Missing $inserted. <inserted text>$
l.10 \begin{bmatrix}

?
! Missing $inserted. <inserted text>$
l.15 \end {bmatrix}
\\
?

Underfull \hbox (badness 10000) in paragraph at lines 10--16


• The ! Missing $inserted. messages are generated because bmatrix must occur in math mode. • There should be no blank lines in math mode. • To center-set an equation (or matrix) without generating an equation number, use $ and $ directives. They initiate and terminate display-math mode, which centers its contents horizontally. • The \sc command does not take an argument. Moreover, it's deprecated under LaTeX2e. Do please replace \newtheorem*{definition}{\sc{Definition}} with \newtheorem*{definition}{\scshape Definition}. • The Underfull \hbox (badness 10000) message is generated because of the unnecessary \\ directive at the end of the \end {bmatrix}\\ line. With the suggested modifications in place, the code no longer issues error and warning messages. \documentclass{article} \usepackage{amsthm,amsmath,amssymb} \newtheorem*{definition}{\scshape Definition} \begin{document} \begin{definition} Determinant of a$3 * 3$grid. For a$3 * 3$grid, given as $\begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i \end{bmatrix}$ The determinant is:$ a (ei-hf) - b (di -gf) + c (dh - ge)$\end{definition} \end{document}  Another alternative can be to use the enviroment center to centre a matrix: \documentclass{article} \usepackage{amsthm} \usepackage{amsmath} \usepackage{amssymb} \usepackage[margin=1.25in]{geometry} \usepackage[shortlabels]{enumitem} \usepackage{graphicx} \usepackage{fancyhdr} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{1pt} \fancyhfoffset{0.2cm} \pagestyle{fancy} \rfoot{redacted} \addtolength{\footskip}{0.2in} \newtheorem*{theorem}{\sc{Theorem}} \newtheorem*{definition}{\sc{Definition}} \newtheorem*{proposition}{\sc{Proposition}} \newtheorem*{corollary}{\sc{Corollary}} \newtheorem*{claim}{\sc{Claim}} \newtheorem*{properties}{\sc{Properties}} \newtheorem*{remark}{\sc{Remark}} \DeclareMathOperator{\N}{\mathbb{N}} \DeclareMathOperator{\Z}{\mathbb{Z}} \DeclareMathOperator{\Q}{\mathbb{Q}} \DeclareMathOperator{\R}{\mathbb{R}} \DeclareMathOperator{\C}{\mathbb{C}} \begin{document} \begin{definition} For a$3 * 3$grid, given as \begin{center}%%%%%%%%%%%%%%%%%%%%%% <- start enviroment center$\begin{bmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{bmatrix}$\end{center} \vspace{5mm} %5mm vertical space The determinant is:$ a (ei-hf) - b (di -gf) + c (dh - ge)\$
\end{definition}
\end{document}