如何使表格宽度延伸到页面

如何使表格宽度延伸到页面

怎么样?我的代码和结果如下

\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}

我试图让它看起来像 在此处输入图片描述

答案1

您发布的图像不是tabular由您发布的代码制作的,但可能是误用了?tabular*。您可以tabular*按如下所示使用,但正如您所见,拉伸表格的效果只是使其更难阅读。

在此处输入图片描述

\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}

答案2

仅供参考,表格版本

  • 没有垂直线,并且
  • 按照包装规则,水平线更少,垂直间距更好booktabs
  • 正如 David Carlisle 指出的那样,为了提高可读性,表格并没有水平拉伸。
  • 数字在小数点处对齐(指数格式的数字除外)。包siunitx与表列类型一起使用S
  • \addlinespace相机设置由一小段垂直空间(包装)隔开booktabs

完整示例:

\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 \\
    \addlinespace
    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 \\
    \addlinespace
    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}

结果

答案3

的使用array只会让事情变得不必要地复杂化。我只需将数字直接放在表格中即可。

为了使数字与小数点对齐,我添加了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}

在此处输入图片描述

离题了,但也许你有兴趣读一下https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf

相关内容