tabu 自动/手动表宽度

tabu 自动/手动表宽度

如何让 latex 自动选择列宽,以便每个条目不会进入 \newline ?如何手动设置每列的宽度,同时确保所有宽度总和等于 \columnwidth ?

\begin{table}[t]
    \begin{tabu} to \columnwidth { | X[l] || X[c] | X[c] | }
        \hline
        \textbf{Component} & \textbf{Time in ms} & \textbf{Time in \%} \\
        \hline
        Data processing & 42 & 33\\
        \hline
        RANSAC & 2 & 1 \\
        \hline  
        Region Proposals  & 82 & 64 \\
        \hline  
    \end{tabu}
    \caption{Breakdown in the running time our system with a single core machine. Time in ms is averaged across the validation set.}
    \label{tab:componentruntime}
\end{table}

在此处输入图片描述

答案1

使用良好的tabular*环境:

\documentclass[twocolumn]{article}

\usepackage{lipsum}

\begin{document}

\lipsum[2]

\begin{table}[htp]

\begin{tabular*}{\columnwidth}{  @{\extracolsep{\fill}} |l||c|c| @{} }
\hline
\textbf{Component} & \textbf{Time in ms} & \textbf{Time in \%} \\
\hline
Data processing & 42 & 33\\
\hline
RANSAC & 2 & 1 \\
\hline
Region Proposals  & 82 & 64 \\
\hline
\end{tabular*}

\caption{Breakdown in the running time our system with a single core 
  machine. Time in ms is averaged across the validation set.}
\label{tab:componentruntime}

\end{table}

\lipsum

\end{document}

在此处输入图片描述

强制版本,有booktabs且无垂直线。第一列左对齐使得双垂直线不再必要(实际上,它从来都不是)。由于条目不跨行分割,因此水平线可以减少到最低限度。

\documentclass[twocolumn]{article}
\usepackage{booktabs}

\usepackage{lipsum}

\begin{document}

\lipsum[2]

\begin{table}[htp]

\begin{tabular*}{\columnwidth}{  @{\extracolsep{\fill}} lcc @{} }
\toprule
\textbf{Component} & \textbf{Time in ms} & \textbf{Time in \%} \\
\midrule
Data processing & 42 & 33\\
RANSAC & 2 & 1 \\
Region Proposals  & 82 & 64 \\
\bottomrule
\end{tabular*}

\caption{Breakdown in the running time our system with a single core 
  machine. Time in ms is averaged across the validation set.}
\label{tab:componentruntime}

\end{table}

\lipsum

\end{document}

在此处输入图片描述

通过加载,siunitx您可以轻松获得图形的对齐。

\documentclass[twocolumn]{article}
\usepackage{booktabs}
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}

\lipsum[2]

\begin{table}[htp]

\begin{tabular*}{\columnwidth}{
  @{\extracolsep{\fill}}
  l
  S[table-format=2.0]
  S[table-format=2.0]
  @{}
 }
\toprule
\textbf{Component} & \textbf{Time in ms} & \textbf{Time in \%} \\
\midrule
Data processing & 42 & 33\\
RANSAC & 2 & 1 \\
Region Proposals  & 82 & 64 \\
\bottomrule
\end{tabular*}

\caption{Breakdown in the running time our system with a single core 
  machine. Time in ms is averaged across the validation set.}
\label{tab:componentruntime}

\end{table}

\lipsum

\end{document}

在此处输入图片描述

相关内容