7

Possible Duplicate:
Is there a way to slightly shrink a table, including font size, to fit within the column boundaries?

I have a 16x16 pmatrix. How do i set the width so it doesn't overflow my column? E.g. something like [width = 0.9\columnwidth].

I do not want to have to manually adjust the spacing, which by the way, seems too wide to me anyway.

Ferguzz
  • 587

2 Answers2

11

You can use \resizebox from the graphicx package. Here I have used the [showframe] option of the geometry package so that the column edges are visible:

enter image description here

If you don't want the matrix to use the full line width you can use {0.9\linewidth} so that it re sizes to 90% of the line width.

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}

\begin{document}
\noindent
$\begin{pmatrix}
 Column1 & Column2 & Column3 & Column4 & Column5 & Column6 & Column7 & Column8 & Column9
\end{pmatrix}$

\noindent
\resizebox{\linewidth}{!}{%
$\begin{pmatrix}
 Column1 & Column2 & Column3 & Column4 & Column5 & Column6 & Column7 & Column8 & Column9
\end{pmatrix}$%
}
\end{document}
Peter Grill
  • 223,288
  • \resizebox{\linewidth}{!}{% otherwise you'll get an unwanted space. Same before the closing } –  Jan 02 '12 at 16:57
  • thanks. good answer and does what i need. i am still intrigued as to how to set the default spacing for pmatrix. i will post here if i do find out. – Ferguzz Jan 02 '12 at 20:16
10

To set horizontal spacing in math arrays: \setlength{\arraycolsep}{3pt}.

Default is 6pt.

Source: http://www.eng.cam.ac.uk/help/tpl/textprocessing/squeeze.html

Ferguzz
  • 587
  • Even though this fixes the width between columns in an array (pmatrix is typeset in using an array) to 3pt, which is less than the default 6pt, does it really answer your question? Remember, in this Q&A format, the "Answer" section is devoted to answers. – Werner Jan 03 '12 at 01:25
  • yes this exactly the answer i was searching for. in the question what i meant by 'I do not want to have to manually adjust the spacing' was 'I do not want to have to manually adjust the spacing using ! for each entry.' perhaps i should have been more clear. – Ferguzz Jan 03 '12 at 01:27
  • True. However, such things only become clear once you've examined the answers clearly. For tabular spacing and future reference, see Column padding in tables. – Werner Jan 03 '12 at 01:48