![如何使长表水平适合论文](https://linux22.com/image/463151/%E5%A6%82%E4%BD%95%E4%BD%BF%E9%95%BF%E8%A1%A8%E6%B0%B4%E5%B9%B3%E9%80%82%E5%90%88%E8%AE%BA%E6%96%87.png)
我在 LaTex 中有一张长表格,我需要将其水平放置在我的论文中,但我不知道该怎么做。目前,我的表格就像屏幕截图中显示的那样:。
我的表格的 LaTex 代码如下:
\begin{table}[!ht]
\centering
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
Lineage & Max. Temp. & Avg. Temp. & Avg. Pow. Now & Max freq. big & Mode freq. big & Max freq. LITTLE & Mode freq. LITTLE & Max freq. gpu & Mode freq. gpu & Max gpu busy & Mode gpu busy & Mode FPS \\ \hline
Default & 68 & 58.94 & 7.89 & 1.794 & 1.469 & 1.794 & 1.794 & 0.455 & 0.26 & 54 & 29 & 60 \\ \hline
HH & 63 & 56.27 & 7.5 & 1.69 & 1.17 & 1.69 & 1.69 & 0.455 & 0.26 & 58 & 32 & 60 \\ \hline
MH & 60 & 55.58 & 5.59 & 1.17 & 1.17 & 1.053 & 1.053 & 0.338 & 0.26 & 66 & 29 & 60 \\ \hline
ML & 57 & 53.85 & 4.25 & 0.962 & 0.962 & 0.832 & 0.832 & 0.338 & 0.26 & 53 & 30 & 50 \\ \hline
LL & 54 & 52.07 & 3.45 & 0.65 & 0.65 & 0.455 & 0.455 & 0.455 & 0.26 & 41 & 28 & 40 \\ \hline
\end{tabular}
\end{table}
你知道怎样才能将这张长表水平放置在页面上吗?
答案1
你知道怎样才能将这张[宽]表格水平放置在页面中吗?
由于您没有提供所使用的文档类别、字体系列、字体大小和边距宽度的信息,因此我只能假设系统默认设置适用。如果此假设错误,请提供相关缺失信息。
下面的截图和代码显示,如果你不愿意修改视觉网格模式,你需要从环境切换tabular
到tabularx
环境最低限度,同时切换到 a\small
或(更好的)\footnotesize
相对字体大小——参见表 2 和表 3。通过这些修改,表格可能“适合”;但是,标题行看起来很糟糕。
表 4 显示了如何通过以下方式进行改进:(a) 为标题行提供一些层次结构;(b) 省略所有垂直线并使用较少但间距适当的水平线。
你能猜出我推荐哪个版本吗?
\documentclass{article}
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{L}{>{\RaggedRight}X}
\newcommand\mc[1]{\multicolumn{2}{c}{#1}}
\newcommand{\blobA}{%
\hline
Lineage & Max. Temp. & Avg. Temp. & Avg. Pow. Now & Max freq. big & Mode freq. big & Max freq. LITTLE & Mode freq. LITTLE & Max freq. gpu & Mode freq. gpu & Max gpu busy & Mode gpu busy & Mode FPS \\
\hline}
\newcommand\blobB{%
Default & 68 & 58.94 & 7.89 & 1.794 & 1.469 & 1.794 & 1.794 & 0.455 & 0.26 & 54 & 29 & 60 \\ \hline
HH & 63 & 56.27 & 7.5 & 1.69 & 1.17 & 1.69 & 1.69 & 0.455 & 0.26 & 58 & 32 & 60 \\ \hline
MH & 60 & 55.58 & 5.59 & 1.17 & 1.17 & 1.053 & 1.053 & 0.338 & 0.26 & 66 & 29 & 60 \\ \hline
ML & 57 & 53.85 & 4.25 & 0.962 & 0.962 & 0.832 & 0.832 & 0.338 & 0.26 & 53 & 30 & 50 \\ \hline
LL & 54 & 52.07 & 3.45 & 0.65 & 0.65 & 0.455 & 0.455 & 0.455 & 0.26 & 41 & 28 & 40 \\
\hline}
\newcommand\blobAmod{%
\toprule
Lineage & \mc{Temp} & APN & \mc{freq.\ big} & \mc{freq.\ little} & \mc{freq.\ gpu} & \mc{gpu busy} & MF \\
\cmidrule(lr){2-3} \cmidrule(lr){5-6} \cmidrule(lr){7-8} \cmidrule(lr){9-10} \cmidrule(lr){11-12}
& max & avg& & max & mode & max & mode & max & mode & max & mode & \\
\midrule}
\newcommand\blobBmod{%
Default & 68 & 58.94 & 7.89 & 1.794 & 1.469 & 1.794 & 1.794 & 0.455 & 0.26 & 54 & 29 & 60 \\
HH & 63 & 56.27 & 7.5 & 1.69 & 1.17 & 1.69 & 1.69 & 0.455 & 0.26 & 58 & 32 & 60 \\
MH & 60 & 55.58 & 5.59 & 1.17 & 1.17 & 1.053 & 1.053 & 0.338 & 0.26 & 66 & 29 & 60 \\
ML & 57 & 53.85 & 4.25 & 0.962 & 0.962 & 0.832 & 0.832 & 0.338 & 0.26 & 53 & 30 & 50 \\
LL & 54 & 52.07 & 3.45 & 0.65 & 0.65 & 0.455 & 0.455 & 0.455 & 0.26 & 41 & 28 & 40 \\
\bottomrule}
\begin{document}
% OP's code ('tabular')
\begin{table}[!ht]
\begin{tabular}{|l| *{12}{l|}}
\blobA\blobB
\end{tabular}
\end{table}
% tabularx, \small
\begin{table}[!h]
\setlength\tabcolsep{2pt} % default: 6pt
\small
\begin{tabularx}{\textwidth}{|l| *{12}{L|}}
\blobA\blobB
\end{tabularx}
\end{table}
% tabularx, \footnotesize
\begin{table}[!h]
\setlength\tabcolsep{2pt}
\footnotesize
\begin{tabularx}{\textwidth}{|l| *{12}{L|}}
\blobA\blobB
\end{tabularx}
\end{table}
% tabular, \small, organize header row ("\blobAmod");
% no vert. lines and fewer but well-spaced horiz. lines
% ("\blobBmod").
\begin{table}[!h]
\setlength\tabcolsep{3pt}
\small
\begin{tabularx}{\textwidth}{@{} l *{11}{L} l @{}}
\blobAmod\blobBmod
\addlinespace
\multicolumn{13}{@{}l}{\footnotesize APN: Avg. Pow. Now; MF: Mode FPS.}
\end{tabularx}
\end{table}
\end{document}
答案2
另一个想法是旋转列标题:
\documentclass{article}
\usepackage{geometry}
\usepackage{rotating, makecell}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\begin{document}
\begin{table}[!ht]
\small
\settowidth\rotheadsize{Mode freq.} % from makecell
\begin{tblr}{hlines, vlines,
colspec = {l X[c]
X[c, si={table-format=2.2}]
X[c, si={table-format=1.2}]
*{6}{X[c, si={table-format=1.3}]}
*{3}{X[c, si={table-format=2.0}]} },
colsep = 3pt,
row{1} = {guard, c, cmd=\rothead}
}
Lineage & Max. Temp. & Avg. Temp. & Avg. Pow. Now & Max freq. big & Mode freq. big & Max freq. LITTLE & Mode freq. LITTLE & Max freq. gpu & Mode freq. gpu & Max gpu busy & Mode gpu busy & Mode FPS \\
Default & 68 & 58.94 & 7.89 & 1.794 & 1.469 & 1.794 & 1.794 & 0.455 & 0.26 & 54 & 29 & 60 \\
HH & 63 & 56.27 & 7.5 & 1.69 & 1.17 & 1.69 & 1.69 & 0.455 & 0.26 & 58 & 32 & 60 \\
MH & 60 & 55.58 & 5.59 & 1.17 & 1.17 & 1.053 & 1.053 & 0.338 & 0.26 & 66 & 29 & 60 \\
ML & 57 & 53.85 & 4.25 & 0.962 & 0.962 & 0.832 & 0.832 & 0.338 & 0.26 & 53 & 30 & 50 \\
LL & 54 & 52.07 & 3.45 & 0.65 & 0.65 & 0.455 & 0.455 & 0.455 & 0.26 & 41 & 28 & 40 \\
\end{tblr}
\end{table}
\end{document}