我有一张如下所示的表格,我想通过 更改其编号\renewcommand\thetable{1S}
。但是,我不确定为什么它不起作用。你能帮忙吗?
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{pdflscape}
\usepackage{makecell}
\usepackage{lscape}
\begin{document}
\begin{landscape}
\setlength\LTcapwidth{\textheight}
\setlength\tabcolsep{2.5pt} % default: 6pt
\scriptsize
\vspace{-0.5cm}
\begin{longtable}{@{} l | *{3}{lll|} lll| l | *{3}{lll|} lll @{}} % 26 columns in all
\caption{Comparison of solution approaches using theoretical instances (values are in average)}
\label{tab-theo1} \\
\hline
\multirow{3}{*}{Inst.} &
\multicolumn{3}{l|}{\makecell{Mathematical \\ programming}} &
\multicolumn{3}{l|}{\makecell{NA-ACO \\ algorithm}} &
\multicolumn{3}{l|}{\makecell{Heuristic \\ algorithm}} &
\multirow{2}{*}{\makecell{GAP1 \\ (\%)}} &
\multirow{2}{*}{\makecell{GAP2 \\ (\%)}} &
\multirow{2}{*}{\makecell{GAP3 \\ (\%)}} &
\multirow{3}{*}{Inst.} &
\multicolumn{3}{l|}{\makecell{Mathematical \\ programming}} &
\multicolumn{3}{l|}{\makecell{NA-ACO \\ algorithm}} &
\multicolumn{3}{l|}{\makecell{Heuristic \\ algorithm}} &
\multirow{2}{*}{\makecell{GAP1 \\ (\%)}} &
\multirow{2}{*}{\makecell{GAP2 \\ (\%)}} &
\multirow{2}{*}{\makecell{GAP3 \\ (\%)}} \\
\cline{2-10} \cline{15-23}
& HPI & FS\# & \makecell{CPUT \\ (min)}
& HPI & FS\# & \makecell{CPUT \\ (min)}
& HPI & FS\# & \makecell{CPUT \\ (min)}
& & & &
& HPI & FS\# & \makecell{CPUT \\ (min)}
& HPI & FS\# & \makecell{CPUT \\ (min)}
& HPI & FS\# & \makecell{CPUT \\ (min)}
& & & \\
\hline
%% body of table
% Table generated by Excel2LaTeX from sheet 'Sheet1'
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3 & 34 & 0.87 & 10 & 7.6 & 0.79 & 10 & 11.73 & 0.97 & 10 & 0.29 & 12.4 & 20.6 & 2.3 \\\hline
\end{longtable}
\end{landscape}
\end{document}
答案1
在带有标题编号的一系列表格之前插入:
\setcounter{table}{0}
\renewcommand\thetable{\arabic{table}S}
无关:
看看你是否接受使用tabularray
包并旋转一些列标题。使用它们,表格可以有更大的字体,并将变成这样:
表格上方的虚拟文本仅用于比较表格宽度和表格中使用的字体大小。MWE 为:
\documentclass[11pt]{article}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{rotating} % new
\usepackage{makecell}
\usepackage{tabularray} % new
\UseTblrLibrary{booktabs}
\usepackage{pdflscape}
\usepackage{lipsum}
\begin{document}
\begin{landscape}
\lipsum[66]
\begingroup
\setcounter{table}{0} % new
\renewcommand\thetable{\arabic{table}S} % new
\settowidth\rotheadsize{GAP1 (\%) } % from makecell
\SetTblrStyle{caption}{font=\small}
\SetTblrStyle{caption-tag}{font=\bfseries}
\begin{longtblr}[
caption = {Comparison of solution approaches using theoretical instances
(values are in average)},
label = {tab-theo1},
]{
rowhead = 2,
colsep = 3.4pt,
colspec = {@{} c | *{3}{ccc|} ccc| c | *{3}{ccc|} ccc @{}},
rows = {font=\small, m},
row{3-Z} = {rowsep = 0pt}
}
\toprule
\SetCell[r=2]{cmd=\rotcell} Instrument?
& \SetCell[c=3]{c} {Mathematical \\ programming} & &
& \SetCell[c=3]{c} {NA-ACO \\ algorithm} & &
& \SetCell[c=3]{c} {Heuristic \\ algorithm} & &
& \SetCell[r=2]{cmd=\rotcell} GAP1 (\%)
& \SetCell[r=2]{cmd=\rotcell} GAP2 (\%)
& \SetCell[r=2]{cmd=\rotcell} GAP3 (\%)
& \SetCell[r=2]{c} Inst.
& \SetCell[c=3]{c} {Mathematical \\ programming} & &
& \SetCell[c=3]{c} {NA-ACO \\ algorithm} & &
& \SetCell[c=3]{c} {Heuristic \\ algorithm} & &
& \SetCell[r=2]{cmd=\rotcell} GAP1 (\%)
& \SetCell[r=2]{cmd=\rotcell} GAP2 (\%)
& \SetCell[r=2]{cmd=\rotcell} GAP3 (\%) \\
\midrule
& HPI & FS\# & {CPUT \\ (min)}
& HPI & FS\# & {CPUT \\ (min)}
& HPI & FS\# & {CPUT \\ (min)}
& & & &
& HPI & FS\# & {CPUT \\ (min)}
& HPI & FS\# & {CPUT \\ (min)}
& HPI & FS\# & {CPUT \\ (min)}
& & & \\
\midrule
%% body of table
% Table generated by Excel2LaTeX from sheet 'Sheet1'
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3
& 34 & 0.87 & 10 & 7.6 & 0.79 & 10 & 11.73 & 0.97 & 10 & 0.29 & 12.4 & 20.6
& 2.3 \\
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3
& 34 & 0.87 & 10 & 7.6 & 0.79 & 10 & 11.73 & 0.97 & 10 & 0.29 & 12.4 & 20.6
& 2.3 \\
\addlinespace
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3
& 34 & 0.87 & 10 & 7.6 & 0.79 & 10 & 11.73 & 0.97 & 10 & 0.29 & 12.4 & 20.6
& 2.3 \\
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3
& 34 & 0.87 & 10 & 7.6 & 0.79 & 10 & 11.73 & 0.97 & 10 & 0.29 & 12.4 & 20.6
& 2.3 \\
\bottomrule
\end{longtblr}
\endgroup
\end{landscape}
\end{document}
答案2
无关受@Zarko 的回答启发,另一个想法是如何改进您的格式。我已经去掉了所有垂直线。另外,您的表格似乎重复了,因此我将其减少到 13 列。生成的表格适合纵向页面,并且在我看来令人赏心悦目。
\documentclass[11pt]{article}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{rotating} % new
\usepackage{makecell}
\usepackage{tabularray} % new
\UseTblrLibrary{booktabs}
\usepackage{lipsum}
\begin{document}
\lipsum[66]
\begingroup
\setcounter{table}{0} % new
\renewcommand\thetable{\arabic{table}S} % new
\settowidth\rotheadsize{GAP1 (\%) } % from makecell
\begin{longtblr}[
caption = {Comparison of solution approaches using theoretical instances
(values are in average)},
label = {tab-theo1},
]{
rowhead = 2,
colspec = {@{} *{13}{Q[c,m]} @{}},
row{1-2} = {font=\small}, row{2} = {belowsep=0pt},
row{3-Z} = {rowsep = 0pt}, row{3}= {abovesep=4pt}
}
\toprule
\SetCell[r=2]{cmd=\rotcell} Instrument?
& \SetCell[c=3]{c} {Mathematical \\ programming} & &
& \SetCell[c=3]{c} {NA-ACO \\ algorithm} & &
& \SetCell[c=3]{c} {Heuristic \\ algorithm} & &
& \SetCell[r=2]{cmd=\rotcell} GAP1 (\%)
& \SetCell[r=2]{cmd=\rotcell} GAP2 (\%)
& \SetCell[r=2]{cmd=\rotcell} GAP3 (\%) \\
\cmidrule[lr]{2-4}\cmidrule[lr]{5-7}\cmidrule[lr]{8-10}
& HPI & FS\# & {CPUT \\ (min)}
& HPI & FS\# & {CPUT \\ (min)}
& HPI & FS\# & {CPUT \\ (min)}
& & & \\
\midrule[leftpos=-1, rightpos=-1]
%% body of table
% Table generated by Excel2LaTeX from sheet 'Sheet1'
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3 \\
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3 \\
\addlinespace
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3 \\
1 & 1 & 10 & 0.85 & 1 & 10 & 0.03 & 1 & 10 & 0.13 & 0 & 0 & 0.3 \\
\bottomrule
\end{longtblr}
\endgroup
\end{document}
您还可以考虑使用包S
中的类型列siunitx
。如果您的数字位数不同,它们将改善格式。