3
\[
\colvec[1.7]{(-(1+\mathbf{J_{ee}})) & \mathbf{J_{ep}}& \mathbf{J_{es}}\\
\mathbf{J_{pe}} & -(1 + \mathbf{J_{pp}}) & -\mathbf{J_{ps}}\\
\mathbf{J_{se}} & -\mathbf{J_{sp}} & -(1 + \mathbf{J_{ss}})}\\
\colvec[1.7]{\hat{\bm{r_{e}}}\\
\hat{\bm{r_{p}}}\\ 
\hat{\bm{r_{s}}}}\\
\]

keeping getting an error: undefined control sequence and idk why

\documentclass{article}
\usepackage{graphicx,amsmath}
\newcommand{\colvec}[2][.8]{%
  \scalebox{#1}{%
    \renewcommand{\arraystretch}{.8}%
    $\begin{bmatrix}#2\end{bmatrix}$%
  }
}

\begin{document} \title{Summer Project} \author{Author} \date{\today}

\maketitle

[ \colvec[1.7]{(-(1+\mathbf{J_{ee}})) & \mathbf{J_{ep}}& \mathbf{J_{es}}\ \mathbf{J_{pe}} & -(1 + \mathbf{J_{pp}}) & -\mathbf{J_{ps}}\ \mathbf{J_{se}} & -\mathbf{J_{sp}} & -(1 + \mathbf{J_{ss}})}\ \colvec[1.7]{\hat{\bm{r_{e}}}\ \hat{\bm{r_{p}}}\ \hat{\bm{r_{s}}}}\

] \end{document}

  • 2
    please always post a complete small document that shows the problem. \colvec is not a command I recognise from any package so getting an undefined command error for that would not be unexpected. – David Carlisle Jul 02 '21 at 14:31
  • 1
    The undefined command error does say which command is undefined, but you have not shown it. If you have not loaded bm then \bm will be undefined. – David Carlisle Jul 02 '21 at 14:32
  • you also appear to have \\ at the top level inside \[...\] but \[ is a single line math display, you can't use \\ – David Carlisle Jul 02 '21 at 14:34
  • oh ok so then what do I use to separate the rows in the matrix? – Robert Csete Jul 02 '21 at 14:45
  • I found the clov command because I couldn't figure out how to change the font size in the matrix any other way – Robert Csete Jul 02 '21 at 14:45
  • you may have found it somewhere on the internet but how can we help if you don't say that. You still haven't said which command is undefined if it is \bm the answer is load bm package, if it is \colvec you need to say what you want it to do, then someone can suggest a definition. You can use \\ inside matrices but not at the top level of \[ – David Carlisle Jul 02 '21 at 14:57
  • \documentclass{article} \usepackage{graphicx,amsmath} \newcommand{\colvec}[2][.8]{% \scalebox{#1}{% \renewcommand{\arraystretch}{.8}% $\begin{bmatrix}#2\end{bmatrix}$% } }

    \begin{document} \title{Summer Project} \author{Robert Csete} \date{\today}

    \maketitle

    [ \colvec[1.7]{(-(1+\mathbf{J_{ee}})) & \mathbf{J_{ep}}& \mathbf{J_{es}}\ \mathbf{J_{pe}} & -(1 + \mathbf{J_{pp}}) & -\mathbf{J_{ps}}\ \mathbf{J_{se}} & -\mathbf{J_{sp}} & -(1 + \mathbf{J_{ss}})}\ \colvec[1.7]{\hat{\bm{r_{e}}}\ \hat{\bm{r_{p}}}\ \hat{\bm{r_{s}}}}\ ]

    – Robert Csete Jul 02 '21 at 15:09
  • https://tex.stackexchange.com/questions/58935/matrix-in-small-size – Robert Csete Jul 02 '21 at 15:11
  • that's where I found it – Robert Csete Jul 02 '21 at 15:11
  • Well, as @DavidCarlisle pointed out twice you need to load the bm package you want to use the macro \bm. – campa Jul 02 '21 at 15:18
  • 1
    @campa you forgot to say what an excellent package it is:-) – David Carlisle Jul 02 '21 at 15:36

2 Answers2

3

The error from the posted document is

! Undefined control sequence.
<recently read> \bm

l.23 \hat{\bm{r_{s}}}} \ ?

as you have not loaded bm to define \bm.

adding \usepackage{bm}`

The error becomes

! Missing $ inserted.
<inserted text> 
                $
l.25

?

as you can not have a blank line in math, deleting the line before \] it runs without error producing

enter image description here

But note that the \\ in your input are silently ignored as \[ is always a single line display.

The spacing looks weirdly large as it is scaled up by 1.7 here (and latex then warns the display is too wide for the page) I would use a standard bmatrix

enter image description here

\documentclass{article}
\usepackage{graphicx,amsmath}
\usepackage{bm}

\begin{document} \title{Summer Project} \author{Author} \date{\today}

\maketitle

[ \begin{bmatrix} (-(1+\mathbf{J_{ee}})) & \mathbf{J_{ep}}& \mathbf{J_{es}}\ \mathbf{J_{pe}} & -(1 + \mathbf{J_{pp}}) & -\mathbf{J_{ps}}\ \mathbf{J_{se}} & -\mathbf{J_{sp}} & -(1 + \mathbf{J_{ss}}) \end{bmatrix} \begin{bmatrix} \hat{\bm{r_{e}}}\ \hat{\bm{r_{p}}}\ \hat{\bm{r_{s}}} \end{bmatrix} ] \end{document}

David Carlisle
  • 757,742
3

In addition to loading the bm package and reverting to using two bmatrix environments, as @DavidCarlisle does in his answer, I would also (a) place the \hat symbols solely above \bm{r} and (b) not boldface the subscript terms.

enter image description here

I must confess to not understanding why the J terms are rendered in bold upright math (via \mathbf) whereas the r terms are rendered in bold italic math (via \bm).

\documentclass{article}
\usepackage{amsmath,bm}
\begin{document}
\[
\begin{bmatrix}
-(1+\mathbf{J}_{ee}) & \mathbf{J}_{ep}        & \mathbf{J}_{es}  \\
\mathbf{J}_{pe}      & -(1 + \mathbf{J}_{pp}) & -\mathbf{J}_{ps} \\
\mathbf{J}_{se}      & -\mathbf{J}_{sp}       & -(1 + \mathbf{J}_{ss}) 
\end{bmatrix}
\begin{bmatrix}
\hat{\bm{r}}_{e} \\
\hat{\bm{r}}_{p} \\ 
\hat{\bm{r}}_{s}
\end{bmatrix}
\]
\end{document}
Mico
  • 506,678