![我得到的是一张丑陋的桌子,而不是一张漂亮整洁的桌子!](https://linux22.com/image/330962/%E6%88%91%E5%BE%97%E5%88%B0%E7%9A%84%E6%98%AF%E4%B8%80%E5%BC%A0%E4%B8%91%E9%99%8B%E7%9A%84%E6%A1%8C%E5%AD%90%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E4%B8%80%E5%BC%A0%E6%BC%82%E4%BA%AE%E6%95%B4%E6%B4%81%E7%9A%84%E6%A1%8C%E5%AD%90%EF%BC%81.png)
这是我用来实现所需表格的一段代码,但在表格的左侧出现了不需要的额外行。
另外,我想将表格命名为“表 1”,但 LaTeX 一直将其命名为“Tab. 1”。
我非常感谢你的帮助。
\begin{table}[h]
\centering
\begin{tabular*}{0.9\textwidth}{@{\extracolsep{\fill} } | c | c | c | c | c |}
\hline
Time - Angle & $45^{\circ}$ & $90 ^{\circ}$ & $180^{\circ} $ & $360^{\circ}$ \\
\hline
0.5 s & 44.22 & 192.71 & 1002.9 & 4118.2\\
\hline
1 s & 12.68 & 41.33 & 157.81 & 650.87 \\
\hline
2 s & 7.14 & 23.47 & 72.51 & 182.65\\
\hline
4 s & 4.41 & 14.43 & 32.05 & 109.12 \\
\hline
\end{tabular*}
\renewcommand{\tablename}{Table 1}
\caption{cost functions}
\label{Table:1}
\end{table}
答案1
当您使用 时@{<stuff>}
,<stuff>
用于列分隔。您已提供
@{\extracolsep{\fill} }
注意包括. 删除此空格。
\documentclass{article}
\begin{document}
\begin{table}
\centering
\begin{tabular*}{0.9\textwidth}{@{\extracolsep{\fill}} | c | c | c | c | c |}
\hline
Time - Angle & $45^{\circ}$ & $90 ^{\circ}$ & $180^{\circ} $ & $360^{\circ}$ \\
\hline
0.5 s & 44.22 & 192.71 & 1002.9 & 4118.2 \\
\hline
1 s & 12.68 & 41.33 & 157.81 & 650.87 \\
\hline
2 s & 7.14 & 23.47 & 72.51 & 182.65 \\
\hline
4 s & 4.41 & 14.43 & 32.05 & 109.12 \\
\hline
\end{tabular*}
\caption{cost functions}
\end{table}
\end{document}
这里有一个booktabs
版:
\documentclass{article}
\usepackage{booktabs,siunitx}
\begin{document}
\begin{table}
\centering
\begin{tabular}{
c % Time - Angle
S[table-format = 2.2] % 45 degrees
S[table-format = 3.2] % 90 degrees
S[table-format = 4.2] % 180 degrees
S[table-format = 4.2] % 360 degrees
}
\toprule
& \multicolumn{4}{c}{Angle} \\
\cmidrule(lr){2-5}
Time & $\ang{45}$ & $\ang{90}$ & $\ang{180} $ & $\ang{360}$ \\
\midrule
\SI{0.5}{\second} & 44.22 & 192.71 & 1002.9 & 4118.2 \\
\SI{1.0}{\second} & 12.68 & 41.33 & 157.81 & 650.87 \\
\SI{2.0}{\second} & 7.14 & 23.47 & 72.51 & 182.65 \\
\SI{4.0}{\second} & 4.41 & 14.43 & 32.05 & 109.12 \\
\bottomrule
\end{tabular}
\caption{cost functions}
\end{table}
\end{document}
答案2
类中有两行代码thesis
负责这个Tab 0.1
。它们是
\def\tableshortname{Tab.}
\renewcommand{\thetable}{\thechapter.\@arabic\c@table}
因此,您需要通过发出以下命令来撤消这两行
\makeatletter
\renewcommand{\thetable}{\@arabic\c@table}
\makeatother
\renewcommand\tableshortname{Table}
页眉中的水平线也来自论文类。
\documentclass[12pt, letterpaper, oneside]{thesis}
\usepackage{lmodern,fontspec,array, multirow, multicol}
\makeatletter
\renewcommand{\thetable}{\@arabic\c@table}
\makeatother
\renewcommand\tableshortname{Table}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular*}{0.9\textwidth}{@{\extracolsep{\fill}}| c | c | c | c | c |}
\hline
Time - Angle & $45^{\circ}$ & $90 ^{\circ}$ & $180^{\circ} $ & $360^{\circ}$ \\
\hline
0.5 s & 44.22 & 192.71 & 1002.9 & 4118.2\\
\hline
1 s & 12.68 & 41.33 & 157.81 & 650.87 \\
\hline
2 s & 7.14 & 23.47 & 72.51 & 182.65\\
\hline
4 s & 4.41 & 14.43 & 32.05 & 109.12 \\
\hline
\end{tabular*}
\caption{cost functions}
\label{Table:1}
\end{table}
\end{document}
答案3
\documentclass{article}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular*}{0.9\textwidth}{|@{\extracolsep{\fill} } c| r| r| r| r|}
\hline
Time - Angle & $45^{\circ}$ & $90 ^{\circ}$ & $180^{\circ} $ & $360^{\circ}$ \\
\hline
0.5 s & 44.22 & 192.71 & 1002.9 & 4118.2\\
\hline
1 s & 12.68 & 41.33 & 157.81 & 650.87 \\
\hline
2 s & 7.14 & 23.47 & 72.51 & 182.65\\
\hline
4 s & 4.41 & 14.43 & 32.05 & 109.12 \\
\hline
\end{tabular*}
%\renewcommand{\tablename}{Table 1}
\caption{cost functions}
\label{Table:1}
\end{table}
\end{document}