# how to make tabular width stretch to page

How ? my code and result below

\chapter*{Camera Calibration Data, \\ Cont'd}

Focal Length in x = 953.58\\
Focal Length in y = 953.58\\
Principal Point = (959.5, 539.5)\\

\begin{tabular}{|c|c|c|}
\hline
Camera 1 & $\begin{array}{ccc} 0.99997 & -0.00769 & 0.00016 \\ -0.00500 & -0.66628 &-0.74569 \\ 0.00585 & 0.74567 & -0.66630 \end{array}$ & 0\\
\hline
Camera 2 &   0& 0\\
\hline
Camera 2 &  0 & 0\\
\hline
Camera 2 &0  & 0\\
\hline
Camera 2 &  0 & 0\\
\hline
Camera 2 &  0 & 0\\
\hline
\end{tabular}


I am trying to make it look like

• Please don't add your code as a screenshot, but as a codeblock. This makes it big enough to actually read and we can simply copy it. And please clarify what your intended output should look like. Commented Nov 24, 2016 at 15:47
• I would not make the effort to use array, simply put the numbers directly into the tabular: pastebin.com/443JajUY Commented Nov 24, 2016 at 16:53
• Aren't all your numbers missing their unit? Commented Nov 24, 2016 at 16:54

The image you posted is not made by tabular from the code you posted but probably a misused? tabular*. You can use tabular* as below but as you see, the effect of stretching the table is just to make it harder to read.

\documentclass{report}
\begin{document}

\chapter*{Camera Calibration Data, \\ Cont'd}

Focal Length in x = 953.58\\
Focal Length in y = 953.58\\
Principal Point = (959.5, 539.5)%no!\\

\begin{center}

\begin{tabular}{|c|c|c|}
\hline
Camera 1 & $\begin{array}{ccc} 0.99997 & -0.00769 & 0.00016 \\ -0.00500 & -0.66628 &-0.74569 \\ 0.00585 & 0.74567 & -0.66630 \end{array}$ & 0\\
\hline
Camera 2 &   0& 0\\
\hline
Camera 2 &  0 & 0\\
\hline
Camera 2 &0  & 0\\
\hline
Camera 2 &  0 & 0\\
\hline
Camera 2 &  0 & 0\\
\hline
\end{tabular}

\end{center}

\begin{center}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}|c|c|c|@{}}
\hline
Camera 1 & $\begin{array}{ccc} 0.99997 & -0.00769 & 0.00016 \\ -0.00500 & -0.66628 &-0.74569 \\ 0.00585 & 0.74567 & -0.66630 \end{array}$ & 0\\
\hline
Camera 2 &   0& 0\\
\hline
Camera 2 &  0 & 0\\
\hline
Camera 2 &0  & 0\\
\hline
Camera 2 &  0 & 0\\
\hline
Camera 2 &  0 & 0\\
\hline
\end{tabular*}

\end{center}

\end{document}

• thanks ! do you know how I can make all the entries center ? I am just trying to learn latex by redoing my old report (attached new image) This is by far tougher than any programming language I have ever learnt. I thought the argument |c|c|c| would make all the entries center
– Kong
Commented Nov 24, 2016 at 16:08
• @kong c does make them center and I would use tabular as in the first table above. tabular* adds extra intercolumn space but only on one side of the | so if using that do not use vertical rules (not using vertical rules is a good idea anyway) Commented Nov 24, 2016 at 16:39

Just FYI, a table version

• without vertical lines, and
• with less horizontal lines including better vertical spacing by the rules of package booktabs.
• As David Carlisle pointed out, for better readability, the table is not horizontally stretched.
• The numbers are aligned at the decimal dot (except the number in exponential format). Package siunitx is used with table column type S.
• The camera settings are separated by a little vertical space (\addlinespace of package booktabs).

Full example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{tabular}{
l
*{3}{S[table-format=-1.5]}
S[table-format=-2.2] % minus sign is larger than the leading 1
}
\toprule
&&&& {Camera Position} \\
& \multicolumn{3}{c}{Rotation Matrix}
& {$[x\;y\;z]^{\mathrm{T}}$}\\
\midrule
Camera 1 &  0.99997 & -0.00769 &  0.00016 &  87.56 \\
& -0.00500 & -0.66628 & -0.74569 & -34.52 \\
&  0.00585 &  0.74567 & -0.66630 &  60.69 \\
Camera 2 & -0.99998 & {7.600e-5}&  0.00628 &  87.69 \\
& -0.00475 &  0.66371 & -0.74797 & 103.14 \\
&  0.00065 &  0.76363 & -0.64565 &  60.62 \\
Camera 3 &  0.99997 & -0.00564 & -0.00567 &  53.15 \\
& -0.00797 & -0.64563 & -0.76361 & -34.13 \\
&  0.00065 &  0.76363 & -0.64565 &  56.51 \\
\bottomrule
\end{tabular}
\end{document}


The usage of array just makes this unnecessarily complicate. I would simply place the numbers directly in the tabular.

To get the numbers aligned with respect to their decimal markers, I added siunitx.

\documentclass{report}
\usepackage{tabularx}
\usepackage{siunitx}

\begin{document}

Focal Length in x = 953.58

Focal Length in y = 953.58

Principal Point = (959.5, 539.5)

\begin{tabularx}{\textwidth}{%
@{}|X|SSS|>{\centering\arraybackslash}X|@{}}
\hline
& 0.99997 & -0.00769 & 0.00016 & \\
Camera 1    & -0.00500 & -0.66628 &-0.74569 & 0\\
& 0.00585 & 0.74567 & -0.66630 & \\
\hline
& 0.99997 & -0.00769 & 0.00016 & \\
Camera 1    & -0.00500 & -0.66628 &-0.74569 & 0\\
& 0.00585 & 0.74567 & -0.66630 & \\
\hline
\end{tabularx}
\end{document}


Off-topic, but perhaps you are interested in reading https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf

• also see wiert.me/2014/04/03/… Commented Nov 24, 2016 at 17:53
• @Zarko Nice link! Commented Nov 24, 2016 at 17:57