5

The rows of all my nx15 matrices have been split onto two lines when I compile my document. This is an example of one, which I've been using the rotating package for since it won't fit onto a page unless it's landscape. However it's still splitting it the same as before, and also does this with a 1x15 matrix whose entries should all fit on one line normally without using the rotating package. I've been getting an "Extra alignment tab has been changed to \cr" message. Can anyone help?

\documentclass{article}
\usepackage{geometry,amsmath,rotating}
\begin{document}
\begin{sideways}
$
\begin{pmatrix}
    0.3754  &  0.1299  &  0.3271  &  0.2008  &  0.1111  &  0.1563  &  0.3446 &  0.1116  &  0.1186  &  0.2424  &  0.1428  &  0.1925  &  0.3882  &  0.1814 &  0.2174 \\
    0.2021  &  0.0812  &  0.1162  &  0.1275  &  0.0556  &  0.0905  &  0.1239 &  0.1081  &  0.3636  &  0.2424  &  0.3497  &  0.1925  &  0.2152  &  0.1026 &  0.1133 \\
    0.0954  &  0.2364  &  0.0812  &  0.3503  &  0.2222  &  0.1563  &  0.1741 &  0.1996  &  0.1186  &  0.0606  &  0.2010  &  0.1925  &  0.1212  &  0.3168 &  0.2174 \\
    0.1327  &  0.0484  &  0.1717  &  0.0931  &  0.1111  &  0.3046  &  0.1741 &  0.3587  &  0.2032  &  0.2424  &  0.1164  &  0.1925  &  0.0987  &  0.0594 &  0.2174 \\
    0.0705  &  0.2364  &  0.1717  &  0.1082  &  0.2222  &  0.1236  &  0.0852 &  0.0596  &  0.0750  &  0.0303  &  0.0774  &  0.0388  &  0.0442  &  0.1026 &  0.0567 \\
    0.0620  &  0.2253  &  0.0507  &  0.0777  &  0.2222  &  0.0782  &  0.0490 &  0.1217  &  0.0581  &  0.1212  &  0.0426  &  0.1518  &  0.0822  &  0.1814 &  0.1133 \\
    0.0620  &  0.0424  &  0.0812  &  0.0424  &  0.0556  &  0.0905  &  0.0490 &  0.0406  &  0.0629  &  0.0606  &  0.0702  &  0.0395  &  0.0503  &  0.0556 &  0.0644 \\
\end{pmatrix}
$
\end{sideways}
\end{document}
Mico
  • 506,678
Lizzie
  • 51
  • 2
    Welcome to TeX.SE. By default, the matrix-like environments of the amsmath package -- matrix, pmatrix, bmatrix, etc -- are not supposed to have more than 10 columns. If your matrix has 15 columns, you should run \setcounter{MaxMatrixCols}{15} in the preamble. – Mico Mar 07 '18 at 13:17

2 Answers2

4

tabstackengine comes with no stinkin' column limits! HOOAH!

Generally, for straightforward things like matrices, the amsmath environments are fully prepared to handle your needs. Where TABstacks can be useful is when the requirement is slightly different from the default configuration. With simple mode settings, tabstackengine can immediately do things like

  1. handle more than 10 columns automaTeXly

  2. change the default inter-column gap

  3. change the default inter-row baselineskip (long stacks) or inter-row vertical gap (short stacks)

  4. change the default matrix mode between text or math

  5. make all columns of equal width

  6. apply a fixed formatting style to all elements (e.g., \displaystyle in math mode or \footnotesize in text mode)

  7. flexible alignments (in the mode of array or tabular)

  8. with the new V2.10 of the package, cell over/underlining in the mode of \cline (called \TABrule or \TABcline{} in the package)

Also, the package remembers the individual cell contents and dimensions (including the content dimensions, the row height/depth, as well as the column width) of the most recently typeset TABstack (or can be queried with a hypothetical TABstack that is not typeset). There are various ways in which one could write macros to take advantage of this information, such as overlaying stuff atop the matrix at known cell locations, deciding on the fly whether to break the typesetting of the matrix into several pieces, etc.

Here is the MWE addressing the OP's matrix:

\documentclass{article}
\usepackage{geometry,rotating,tabstackengine}
\begin{document}
\begin{sideways}
$
\setstacktabbedgap{2ex}
\parenMatrixstack{
    0.3754  &  0.1299  &  0.3271  &  0.2008  &  0.1111  &  0.1563  &  0.3446 &  0.1116  &  0.1186  &  0.2424  &  0.1428  &  0.1925  &  0.3882  &  0.1814 &  0.2174 \\
    0.2021  &  0.0812  &  0.1162  &  0.1275  &  0.0556  &  0.0905  &  0.1239 &  0.1081  &  0.3636  &  0.2424  &  0.3497  &  0.1925  &  0.2152  &  0.1026 &  0.1133 \\
    0.0954  &  0.2364  &  0.0812  &  0.3503  &  0.2222  &  0.1563  &  0.1741 &  0.1996  &  0.1186  &  0.0606  &  0.2010  &  0.1925  &  0.1212  &  0.3168 &  0.2174 \\
    0.1327  &  0.0484  &  0.1717  &  0.0931  &  0.1111  &  0.3046  &  0.1741 &  0.3587  &  0.2032  &  0.2424  &  0.1164  &  0.1925  &  0.0987  &  0.0594 &  0.2174 \\
    0.0705  &  0.2364  &  0.1717  &  0.1082  &  0.2222  &  0.1236  &  0.0852 &  0.0596  &  0.0750  &  0.0303  &  0.0774  &  0.0388  &  0.0442  &  0.1026 &  0.0567 \\
    0.0620  &  0.2253  &  0.0507  &  0.0777  &  0.2222  &  0.0782  &  0.0490 &  0.1217  &  0.0581  &  0.1212  &  0.0426  &  0.1518  &  0.0822  &  0.1814 &  0.1133 \\
    0.0620  &  0.0424  &  0.0812  &  0.0424  &  0.0556  &  0.0905  &  0.0490 &  0.0406  &  0.0629  &  0.0606  &  0.0702  &  0.0395  &  0.0503  &  0.0556 &  0.0644 
}
$
\end{sideways}
\end{document}

enter image description here

  • Just for those of us who aren't fully familiar with \parenMatrixstack, would you maybe add a sentence or two to mention what this macro can, and cannot, do? E.g., what are its pluses relative to the amsmath package's pmatrix environment -- other than the fact that there's no default maximum number of columns? – Mico Mar 07 '18 at 13:49
1

You can use the medsizecommand from nccmath(~80 % of \displaystyle) to make the matrix fit the text height. As the matrix parenthese are a litlle tight for my taste, I added some vertical spacing at the top and bottom of the matrix with the \Gape command from makecell:

\documentclass[showframe]{article}
\usepackage{geometry, mathtools, nccmath, rotating, makecell}
\setcounter{MaxMatrixCols}{20}

\begin{document}

 \begin{center}
    \begin{sideways}
    $ \begin{medsize}
    \begin{pmatrix}
    0.3754 & 0.1299 & 0.3271 & 0.2008 & 0.1111 & 0.1563 & 0.3446 & 0.1116 & 0.1186 & 0.2424 & 0.1428 & 0.1925 & 0.3882 & 0.1814 & \Gape[1.5ex][0pt]{0.2174}\\
    0.2021 & 0.0812 & 0.1162 & 0.1275 & 0.0556 & 0.0905 & 0.1239 & 0.1081 & 0.3636 & 0.2424 & 0.3497 & 0.1925 & 0.2152 & 0.1026 & 0.1133 \\
    0.0954 & 0.2364 & 0.0812 & 0.3503 & 0.2222 & 0.1563 & 0.1741 & 0.1996 & 0.1186 & 0.0606 & 0.2010 & 0.1925 & 0.1212 & 0.3168 & 0.2174 \\
    0.1327 & 0.0484 & 0.1717 & 0.0931 & 0.1111 & 0.3046 & 0.1741 & 0.3587 & 0.2032 & 0.2424 & 0.1164 & 0.1925 & 0.0987 & 0.0594 & 0.2174 \\
    0.0705 & 0.2364 & 0.1717 & 0.1082 & 0.2222 & 0.1236 & 0.0852 & 0.0596 & 0.0750 & 0.0303 & 0.0774 & 0.0388 & 0.0442 & 0.1026 & 0.0567 \\
    0.0620 & 0.2253 & 0.0507 & 0.0777 & 0.2222 & 0.0782 & 0.0490 & 0.1217 & 0.0581 & 0.1212 & 0.0426 & 0.1518 & 0.0822 & 0.1814 & 0.1133 \\
    0.0620 & 0.0424 & 0.0812 & 0.0424 & 0.0556 & 0.0905 & 0.0490 & 0.0406 & 0.0629 & 0.0606 & 0.0702 & 0.0395 & 0.0503 & 0.0556 & \Gape[0pt][1.5ex]{0.0644} \\
    \end{pmatrix}\hskip 4.5em
    \end{medsize} $
    \end{sideways}
\end{center}

\end{document} 

enter image description here

Bernard
  • 271,350