我在使用 tabu 时遇到了问题,当我使用下面的代码制作表格时,第一行最后一列的内容并不是全部可见的。这是为什么?
\begin{table}[h]
\caption{Explanation }
\label{table:browsing_history}
\begin{center}
\begin{tabu} to 1.0\textwidth{|c|c|c|c|X[m,c]|}
\hline
User & Contacts & Timestamp & Restaurant & Ranking of selected restaurant \\ \hline
1 & ~ & 13.6.2013.10.33.43 & Restaurang Upper East & 3 \\ \hline
1 & 2,3 & 13.6.2013.10.34.2 & World Class & 2 \\ \hline
3 & 4 & 14.6.2013.11.10.19 & Secret Recipe & 10 \\ \hline
\end{tabu}
\end{center}
\end{table}
答案1
不要使用tabu
(据我所知,新版本有很多错误和兼容性问题);使用tabularx
反而:
\documentclass{article}
\usepackage[margin=4cm]{geometry}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}
\caption{Explanation}
\label{table:browsing_history}
\centering
\setlength\extrarowheight{3pt}
\begin{tabularx}{\textwidth}{|c|c|c|c|C|}
\hline
User & Contacts & Timestamp & Restaurant & Ranking of selected restaurant \\ \hline
1 & ~ & 13.6.2013.10.33.43 & Restaurang Upper East & 3 \\ \hline
1 & 2,3 & 13.6.2013.10.34.2 & World Class & 2 \\ \hline
3 & 4 & 14.6.2013.11.10.19 & Secret Recipe & 10 \\ \hline
\end{tabularx}
\end{table}
\end{document}
注意添加了一些额外的空间
\setlength\extrarowheight{3pt}
(谢谢大卫·卡莱尔针对此建议)。
也许你可能对booktabs
包装以生成漂亮的表格(不允许垂直线)。
这是带有书页标签的表格:
\documentclass{article}
\usepackage[margin=4cm]{geometry}
\usepackage{tabularx}
\usepackage{booktabs}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[h]
\caption{Explanation }
\label{table:browsing_history}
\centering
\begin{tabularx}{\textwidth}{ccccC}
\toprule
User & Contacts & Timestamp & Restaurant & Ranking of selected restaurant \\ \midrule
1 & ~ & 13.6.2013.10.33.43 & Restaurang Upper East & 3 \\
1 & 2,3 & 13.6.2013.10.34.2 & World Class & 2 \\
3 & 4 & 14.6.2013.11.10.19 & Secret Recipe & 10 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
center
还请注意,我使用的环境不是\centering
用来防止额外垂直空间的。
答案2
抱歉,不是评论,但无法添加图片。请给出 MWE。在干净的article
:
\documentclass{article}
\usepackage{tabu}
\textwidth14cm
\begin{document}
\begin{table}[h]
\caption{Explanation }
\label{table:browsing_history}
\begin{center}
%\begin{tabu} to 1.0\textwidth{|c|c|c|c|X[m,c]|}
\begin{tabu} to 1.0\textwidth{|c|c|c|c|X[m,c]|}
\hline
User & Contacts & Timestamp & Restaurant & Ranking of selected restaurant \\ \hline
1 & ~ & 13.6.2013.10.33.43 & Restaurang Upper East & 3 \\ \hline
1 & 2,3 & 13.6.2013.10.34.2 & World Class & 2 \\ \hline
3 & 4 & 14.6.2013.11.10.19 & Secret Recipe & 10 \\ \hline
\end{tabu}
\end{center}
\end{table}
\end{document}
结果如下:
因此,您的情况是混合包装的副作用。