我是 LaTex 的新手,似乎学习难度很高。我有下表:
\begin{table}[ht]
\centering\settowidth\rotheadsize{Next concept/}
\renewcommand\cellalign{cl}
\renewcommand\arraystretch{1.25}
\caption{Title}
\begin{tabular}{|l|c|c|c|c}
\toprule\noalign{\vskip-1pt}\hline
\diagbox[height=1.25\rotheadsize]{\raisebox{3ex}{Layers}}{\raisebox{-4ex}{Neurons}} & 10 & 20 & 64 \\
\hline
2 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
4 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
8 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
12 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
\hline\bottomrule
\end{tabular}
\end{table}
有点难以看清,但它继续向右移动太多,这是我主要担心的问题。有没有简单的解决办法?我尝试调整高度和arraystretch
,但似乎没有效果。
答案1
- 显然您的表格比 更宽
\textwidth
。因此,它会突出右文本边框。 - 你可以做什么:
\textwidth
通过装载包来增加geometry
。- 重新设计表格,使第一列更窄。这可以通过省略
\diagbox
并引入新行来实现(请参阅下面的 MWE):
\documentclass{article}
\usepackage{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%
\usepackage{lipsum} % for dummy text
%---------------------------------------------------------------%
\usepackage{booktabs}
\usepackage[skip=1ex]{caption}
\begin{document}
\begin{table}[ht]
\caption{Title}
\label{tab:neurons}
\centering
\renewcommand\arraystretch{1.1}
\begin{tabular}{@{} *{4}{c} @{}}
\toprule
& \multicolumn{3}{c}{Neurons} \\
\cmidrule(l){2-4}
Layers
& 10 & 20 & 64 \\
\midrule
2 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
4 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
8 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
12 & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) & (0.001, 0.008, 0.001, 0.001) \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
- 通过这种改变,表格看起来更加“专业”:
(红线表示页面布局)