# Positioning and spacing of matrices

I have the following matrix as part of the text.

\usepackage{mathtools}

\begin{document}

$B = \begin{bmatrix*}[r] -35833 & -31743 & -25098 & -15178 & 0 & 26332 & 83775 & 278053\\ 139167 & 115894 & 84478 & 42736 & -14684 & -102432 & -261195 & -625923\\ -311667 & -245610 & -168059 & -75042 & 41775 & 203744 & 463854 & 964174\\ 479167 & 354802 & 226562 & 87117 & -73865 & -279459 & -581824 & -1104074\\ -551667 & -379883 & -225687 & -74437 & 86118 & 276252 & 536428 & 953089\\ 479167 & 298423 & 161307 & 41879 & -73865 & -200977 & -364008 & -610219\\ -311667 & -166016 & -79330 & -14573 & 41775 & 98840 & 167683 & 266968\\ 139167 & 51824 & 19223 & -96 & -14684 & -28125 & -43379 & -64691 \end{bmatrix*}$

%omitted text

\end{document}


When I view my document, it looks like this

The matrix stretches too far out right. How do I ensure that it is more centered with respect to the text below?

• Maybe you could try with another size font for that matrix. Jul 31 '15 at 17:33
• @juanuni How do I do that?
Jul 31 '15 at 17:36
• I suggest you read all responses and comments in tex.stackexchange.com/questions/60453/… and choice the one you like. Jul 31 '15 at 17:43
• I was a little unsure with most of the options I'd seen earlier since they involved having to use something like psmallmatrix which leads to the loss of right alignment.
Jul 31 '15 at 17:54
• I was confused because you have a large array as part of a mathematical text inline. Maybe is advisable put your large matrix within $ $ Jul 31 '15 at 18:02

You can play with the value of \arraycolsep, or use the medmath command, from nccmath, which sets the fontsize to ~ 80% of \displaystyle. You also can combine both solutions:

\documentclass[a4paper, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{mathtools, nccmath}

\begin{document}

$\setlength{\arraycolsep}{4pt} B = \begin{bmatrix*}[r] -35833 & -31743 & -25098 & -15178 & 0 & 26332 & 83775 & 278053\\ 139167 & 115894 & 84478 & 42736 & -14684 & -102432 & -261195 & -625923\\ -311667 & -245610 & -168059 & -75042 & 41775 & 203744 & 463854 & 964174\\ 479167 & 354802 & 226562 & 87117 & -73865 & -279459 & -581824 & -1104074\\ -551667 & -379883 & -225687 & -74437 & 86118 & 276252 & 536428 & 953089\\ 479167 & 298423 & 161307 & 41879 & -73865 & -200977 & -364008 & -610219\\ -311667 & -166016 & -79330 & -14573 & 41775 & 98840 & 167683 & 266968\\ 139167 & 51824 & 19223 & -96 & -14684 & -28125 & -43379 & -64691 \end{bmatrix*}$
\vskip1cm
$B = \medmath{\begin{bmatrix*}[r] -35833 & -31743 & -25098 & -15178 & 0 & 26332 & 83775 & 278053\\ 139167 & 115894 & 84478 & 42736 & -14684 & -102432 & -261195 & -625923\\ -311667 & -245610 & -168059 & -75042 & 41775 & 203744 & 463854 & 964174\\ 479167 & 354802 & 226562 & 87117 & -73865 & -279459 & -581824 & -1104074\\ -551667 & -379883 & -225687 & -74437 & 86118 & 276252 & 536428 & 953089\\ 479167 & 298423 & 161307 & 41879 & -73865 & -200977 & -364008 & -610219\\ -311667 & -166016 & -79330 & -14573 & 41775 & 98840 & 167683 & 266968\\ 139167 & 51824 & 19223 & -96 & -14684 & -28125 & -43379 & -64691 \end{bmatrix*}}$

\vskip1cm
$\setlength{\arraycolsep}{3pt} B = \medmath{\begin{bmatrix*}[r] -35833 & -31743 & -25098 & -15178 & 0 & 26332 & 83775 & 278053\\ 139167 & 115894 & 84478 & 42736 & -14684 & -102432 & -261195 & -625923\\ -311667 & -245610 & -168059 & -75042 & 41775 & 203744 & 463854 & 964174\\ 479167 & 354802 & 226562 & 87117 & -73865 & -279459 & -581824 & -1104074\\ -551667 & -379883 & -225687 & -74437 & 86118 & 276252 & 536428 & 953089\\ 479167 & 298423 & 161307 & 41879 & -73865 & -200977 & -364008 & -610219\\ -311667 & -166016 & -79330 & -14573 & 41775 & 98840 & 167683 & 266968\\ 139167 & 51824 & 19223 & -96 & -14684 & -28125 & -43379 & -64691 \end{bmatrix*}}$
\end{document}


• Both options are still a little too large. I tried working with lower arguments to \arraycolsep but the matrix becomes too clustered then. I got a solution as mentioned above.