在这个问题中,我们学习了如何创建跨越多页的表格。
我想进一步说定心第 1 列和第 3 列的内容,同时保留第 2 列的左对齐。以一个简单的 MWE 为例
\documentclass{article}
\usepackage{longtable}
\usepackage{lipsum} % just for dummy text- not needed for a longtable
\usepackage{booktabs}
\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]
%\begin{table}[h]
%\centering
\begin{longtable}{ p{.10\textwidth} p{.60\textwidth} p{.10\textwidth}}
%\begin{adjustbox}{width=0.95\textwidth}
\toprule
ID & Severity & Yes \\
\midrule
foo & bar & . \\
foo & bar & . \\
foo & bar & \\
foo & bar & . \\
foo & bar & . \\
foo & bar & \\
foo & bar & \\
foo & bar & \\
foo & bar & \\
foo & bar & \\
\bottomrule
%\end{adjustbox}
\caption{Your caption here} % needs to go inside longtable environment
\label{tab:myfirstlongtable}
\end{longtable}
%\end{table}
Table \ref{tab:myfirstlongtable} shows my first longtable.
\end{document}
现在我们有
\begin{longtable}{ p{.10\textwidth} p{.60\textwidth} p{.10\textwidth}}
命令,我尝试过
\begin{longtable}{ c{.10\textwidth} p{.60\textwidth} c{.10\textwidth}}
和
\begin{longtable}{clc}{ p{.10\textwidth} p{.60\textwidth} p{.10\textwidth}}
但尚未利用....
答案1
使用数组包并注入\centering
到单元格中。在最后一个单元格中,您还应该将的含义\\
重新设置为表格含义(\centering 会对其进行更改):
\documentclass{article}
\usepackage{longtable,array}
\usepackage{lipsum} % just for dummy text- not needed for a longtable
\usepackage{booktabs}
\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]
%\begin{table}[h]
%\centering
\begin{longtable}{>{\centering}p{.10\textwidth} p{.60\textwidth} >{\centering\arraybackslash}p{.10\textwidth}}
%\begin{adjustbox}{width=0.95\textwidth}
\toprule
ID & Severity & Yes \\
\midrule
foo & bar & . \\
foo & bar & . \\
foo & bar & \\
foo & bar & . \\
foo & bar & . \\
foo & bar & \\
foo & bar & \\
foo & bar & \\
foo & bar & \\
foo & bar & \\
\bottomrule
%\end{adjustbox}
\caption{Your caption here} % needs to go inside longtable environment
\label{tab:myfirstlongtable}
\end{longtable}
%\end{table}
Table \ref{tab:myfirstlongtable} shows my first longtable.
\end{document}