I've been using this thisspringer format latex document and wanted to add a matrix in the paper and I've been bumping into this error for a while now.
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{graphicx}
\graphicspath{ {./imgs/} }
\usepackage{changepage}% http://ctan.org/pkg/changepage
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{booktabs}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\renewenvironment{bmatrix}
{{\ifnum`}=0 \fi\left[\env@matrix}
{\endmatrix\right]\ifnum`{=0 \fi}}
\makeatother
\usepackage{amsmath, xparse}
\usepackage{mathtools}
\newlength{\extratrim}
\setlength{\extratrim}{10mm}
\newcommand*{\trimexpr}[1]{\dimexpr(#1)+\extratrim\relax}
gsave
newpath
20 20 moveto
20 220 lineto
220 220 lineto
220 20 lineto
closepath
2 setlinewidth
gsave
.4 setgray fill
grestore
stroke
grestore
\end{filecontents*}
%
\RequirePackage{fix-cm}
%
%\documentclass{svjour3} % onecolumn (standard format)
%\documentclass[smallcondensed]{svjour3} % onecolumn (ditto)
\documentclass[smallextended]{svjour3} % onecolumn (second format)
%\documentclass[twocolumn]{svjour3} % twocolumn
%
\smartqed % flush right qed marks, e.g. at end of proof
%
\usepackage{graphicx}
%
\usepackage{mathptmx} % use Times fonts if available on your TeX system
%
% insert here the call for the packages your document requires
%\usepackage{latexsym}
% etc.
%
% please place your own definitions here and don't use \def but
% \newcommand{}{}
%
% Insert the name of "your journal" with
% \journalname{myjournal}
%
\begin{document}
\title{Random titl}
\author{me \& him }
\institute{x x of x, \at
Institute of x Technology and Electronics \\
{} % \\
%
\and
x x
x, yy
\and \\
x x
x, yy
}
\date{May 15th 2020}
% The correct dates will be entered by the editor
\maketitle
\[
\begin{bmatrix}
1 2 \\
2 3
\end{bmatrix}
\]
\section{Summary}
\section{Appendix}
%\begin{acknowledgements}
%If you'd like to thank anyone, place your comments here
%and remove the percent signs.
%\end{acknowledgements}
% Authors must disclose all relationships or interests that
% could have direct or potential influence or impart bias on
% the work:
%
% \section*{Conflict of interest}
%
% The authors declare that they have no conflict of interest.
% BibTeX users please use one of
%\bibliographystyle{spbasic} % basic style, author-year citations
%\bibliographystyle{spmpsci} % mathematics and physical sciences
%\bibliographystyle{spphys} % APS-like style for physics
%\bibliography{} % name your BibTeX data base
% Non-BibTeX users please use
\begin{thebibliography}{}
%
% and use \bibitem to create references. Consult the Instructions
% for authors for reference list style.
%
\bibitem{RefJ}
% Format for Journal Reference
Author, Article title, Journal, Volume, page numbers (year)
% Format for books
\bibitem{RefB}
Author, Book title, page numbers. Publisher, place (year)
% etc
\end{thebibliography}
\end{document}
% end of file template.tex
I get an error Environment bmatrix undefined. \begin{bmatrix}
. I also added amsmath package but that didn't seem to help. What could be the problem?
Best Answer
The instruction
has to earlier in the preamble. It should be executed immediately after
\usepackage{booktabs}
at the latest.Why? Because the preamble then redefines the macro
\env@matrix
and the environmentbmatrix
. Both are defined in theamsmath
package. Unsurprisingly, LaTeX crashes if it's told to redefine something that hasn't been defined yet.