尝试在 latex 中重写表格,但是我需要将 sec1 列重写为 sec^1(带上标)
谢谢
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\title{tabulka}
\author{petr102030 Hrobar}
\date{May 2019}
\begin{document}
\maketitle
\section{tabulka}
\begin{sidewaystable}[]
\caption{Instance do 1000 bodů}
\label{do1000}
\begin{tabular}{cccccccccccc}
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{\textbf{CNN}} & \multicolumn{3}{c}{\textbf{CNN-2-opt}} & \multicolumn{4}{c}{\textbf{PMSOM}} \\ \hline
\textbf{Instance} & \multicolumn{1}{c|}{\textbf{Optimum}} & \textbf{sec1} & \textbf{\%rozdíl} & \multicolumn{1}{c|}{\textbf{TPDB}} & \textbf{sec1} & \textbf{\%rozdíl} & \multicolumn{1}{c|}{\textbf{TPDB}} & \textbf{k*} & \textbf{sec1} & \textbf{\%rozdíl2} & \textbf{TPDB} \\
eil51 & \multicolumn{1}{c|}{426} & 0.019 & 18.78 & \multicolumn{1}{c|}{0.004} & 0.019 & 4.23 & \multicolumn{1}{c|}{0.001} & 1 & 0.31 & 1.64 & 0.005 \\
berlin52 & \multicolumn{1}{c|}{7 542} & 0.088 & 8.49 & \multicolumn{1}{c|}{0.007} & 0.019 & \textbf{2.53} & \multicolumn{1}{c|}{0.000} & 1 & 0.36 & 4.29 & 0.015 \\
eil76 & \multicolumn{1}{c|}{538} & 0.110 & 13.94 & \multicolumn{1}{c|}{0.015} & 0.042 & 7.25 & \multicolumn{1}{c|}{0.003} & 1 & 0.67 & 3.72 & 0.025 \\
eil101 & \multicolumn{1}{c|}{629} & 0.066 & 18.60 & \multicolumn{1}{c|}{0.012} & 0.082 & 7.63 & \multicolumn{1}{c|}{0.006} & 1 & 1.31 & 3.72 & 0.049 \\
lin105 & \multicolumn{1}{c|}{14 379} & 0.231 & 17.80 & \multicolumn{1}{c|}{0.041} & 0.094 & 5.30 & \multicolumn{1}{c|}{0.005} & 1 & 1.11 & 3.00 & 0.033 \\
bier127 & \multicolumn{1}{c|}{118 282} & 0.275 & 13.26 & \multicolumn{1}{c|}{0.036} & 0.145 & 5.76 & \multicolumn{1}{c|}{0.008} & 1 & 1.53 & 2.40 & 0.037 \\
ch130 & \multicolumn{1}{c|}{6 110} & 0.269 & 17.82 & \multicolumn{1}{c|}{0.048} & 0.190 & 5.09 & \multicolumn{1}{c|}{0.010} & 2 & 4.53 & 2.39 & 0.108 \\
ch150 & \multicolumn{1}{c|}{6 528} & 0.307 & 8.43 & \multicolumn{1}{c|}{0.026} & 0.200 & \textbf{2.79} & \multicolumn{1}{c|}{0.006} & 2 & 3.01 & 3.30 & 0.099 \\
rat195 & \multicolumn{1}{c|}{2 323} & 0.431 & 16.92 & \multicolumn{1}{c|}{0.073} & 0.320 & 4.43 & \multicolumn{1}{c|}{0.014} & 2 & 5.70 & 4.09 & 0.233 \\
d198 & \multicolumn{1}{c|}{15 780} & 0.433 & 12.86 & \multicolumn{1}{c|}{0.056} & 0.343 & 4.05 & \multicolumn{1}{c|}{0.014} & 2 & 10.52 & 2.09 & 0.220 \\
pr299 & \multicolumn{1}{c|}{48 191} & 0.873 & 20.95 & \multicolumn{1}{c|}{0.183} & 1.362 & 6.02 & \multicolumn{1}{c|}{0.082} & 2 & 7.81 & 3.99 & 0.312 \\
pcb442 & \multicolumn{1}{c|}{50 778} & 2.093 & 16.10 & \multicolumn{1}{c|}{0.337} & 2.621 & 6.06 & \multicolumn{1}{c|}{0.159} & 2 & 11.13 & 5.54 & 0.617 \\
d493 & \multicolumn{1}{c|}{35 002} & 2.431 & 18.56 & \multicolumn{1}{c|}{0.451} & 5.017 & 5.49 & \multicolumn{1}{c|}{0.275} & 3 & 19.52 & 4.55 & 0.889 \\
u574 & \multicolumn{1}{c|}{36 905} & 3.506 & 20.62 & \multicolumn{1}{c|}{0.723} & 7.651 & 7.83 & \multicolumn{1}{c|}{0.599} & 3 & 30.51 & 3.94 & 1.201 \\
d657 & \multicolumn{1}{c|}{48 912} & 4.950 & 23.63 & \multicolumn{1}{c|}{1.170} & 12.671 & 6.62 & \multicolumn{1}{c|}{0.839} & 3 & 22.22 & 4.32 & 0.960 \\
u724 & \multicolumn{1}{c|}{41 910} & 6.410 & 21.94 & \multicolumn{1}{c|}{1.406} & 13.839 & 5.77 & \multicolumn{1}{c|}{0.798} & 3 & 21.41 & 5.30 & 1.136 \\
rat783 & \multicolumn{1}{c|}{8 806} & 7.872 & 21.61 & \multicolumn{1}{c|}{1.701} & 11.748 & 7.81 & \multicolumn{1}{c|}{0.918} & 3 & 19.55 & 6.15 & 1.203 \\ \hline
\multicolumn{3}{l}{1) stanoveno jako průměr z 10 měření} & 17.08 & \multicolumn{1}{c|}{0.37} & & 5.57 & \multicolumn{1}{c|}{0.22} & & & 3.79 & 0.42 \\
\multicolumn{3}{l}{2) dle nejlepší hodnoty z 10 měření} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\ \hline
\end{tabular}
\end{sidewaystable}
\end{document}
答案1
使用\textsuperscript
并简化您的输入:它是很多删除一些垂直线比插入许多垂直线要容易得多\multicolumn
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\begin{document}
\begin{sidewaystable}
\centering
\caption{Instance do 1000 bodů}
\label{do1000}
\begin{tabular}{cc|ccc|ccc|cccc}
\hline
\multicolumn{2}{c}{} &
\multicolumn{3}{c}{\textbf{CNN}} &
\multicolumn{3}{c}{\textbf{CNN-2-opt}} &
\multicolumn{4}{c}{\textbf{PMSOM}} \\
\hline
\textbf{Instance} & \textbf{Optimum} &
\textbf{sec\textsuperscript{1}} & \textbf{\%rozdíl} & \textbf{TPDB} &
\textbf{sec\textsuperscript{1}} & \textbf{\%rozdíl} & \textbf{TPDB} &
\textbf{k*} & \textbf{sec\textsuperscript{1}} & \textbf{\%rozdíl\textsuperscript{2}} & \textbf{TPDB} \\
eil51 & 426 & 0.019 & 18.78 & 0.004 & 0.019 & 4.23 & 0.001 & 1 & 0.31 & 1.64 & 0.005 \\
berlin52 & 7 542 & 0.088 & 8.49 & 0.007 & 0.019 & \textbf{2.53} & 0.000 & 1 & 0.36 & 4.29 & 0.015 \\
eil76 & 538 & 0.110 & 13.94 & 0.015 & 0.042 & 7.25 & 0.003 & 1 & 0.67 & 3.72 & 0.025 \\
eil101 & 629 & 0.066 & 18.60 & 0.012 & 0.082 & 7.63 & 0.006 & 1 & 1.31 & 3.72 & 0.049 \\
lin105 & 14 379 & 0.231 & 17.80 & 0.041 & 0.094 & 5.30 & 0.005 & 1 & 1.11 & 3.00 & 0.033 \\
bier127 & 118 282 & 0.275 & 13.26 & 0.036 & 0.145 & 5.76 & 0.008 & 1 & 1.53 & 2.40 & 0.037 \\
ch130 & 6 110 & 0.269 & 17.82 & 0.048 & 0.190 & 5.09 & 0.010 & 2 & 4.53 & 2.39 & 0.108 \\
ch150 & 6 528 & 0.307 & 8.43 & 0.026 & 0.200 & \textbf{2.79} & 0.006 & 2 & 3.01 & 3.30 & 0.099 \\
rat195 & 2 323 & 0.431 & 16.92 & 0.073 & 0.320 & 4.43 & 0.014 & 2 & 5.70 & 4.09 & 0.233 \\
d198 & 15 780 & 0.433 & 12.86 & 0.056 & 0.343 & 4.05 & 0.014 & 2 & 10.52 & 2.09 & 0.220 \\
pr299 & 48 191 & 0.873 & 20.95 & 0.183 & 1.362 & 6.02 & 0.082 & 2 & 7.81 & 3.99 & 0.312 \\
pcb442 & 50 778 & 2.093 & 16.10 & 0.337 & 2.621 & 6.06 & 0.159 & 2 & 11.13 & 5.54 & 0.617 \\
d493 & 35 002 & 2.431 & 18.56 & 0.451 & 5.017 & 5.49 & 0.275 & 3 & 19.52 & 4.55 & 0.889 \\
u574 & 36 905 & 3.506 & 20.62 & 0.723 & 7.651 & 7.83 & 0.599 & 3 & 30.51 & 3.94 & 1.201 \\
d657 & 48 912 & 4.950 & 23.63 & 1.170 & 12.671 & 6.62 & 0.839 & 3 & 22.22 & 4.32 & 0.960 \\
u724 & 41 910 & 6.410 & 21.94 & 1.406 & 13.839 & 5.77 & 0.798 & 3 & 21.41 & 5.30 & 1.136 \\
rat783 & 8 806 & 7.872 & 21.61 & 1.701 & 11.748 & 7.81 & 0.918 & 3 & 19.55 & 6.15 & 1.203 \\ \hline
&&& 17.08 & 0.37 & & 5.57 & 0.22 & & & 3.79 & 0.42 \\
\hline
\multicolumn{12}{l}{1) stanoveno jako průměr z 10 měření} \\
\multicolumn{12}{l}{2) dle nejlepší hodnoty z 10 měření} \\
\end{tabular}
\end{sidewaystable}
\end{document}
我还在表格下方设置了注释;正如您所见,前三列不足以容纳它们。没有必要为了省一行而牺牲清晰度。
可选参数sidewaystable
不能为空。
一种不同的实现,没有垂直规则,但有booktabs
,更重要的是siunitx
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{siunitx,etoolbox,booktabs}
\begin{document}
\begin{sidewaystable}
\centering
\caption{Instance do 1000 bodů}
\label{do1000}
\robustify\bfseries % for using \bfseries inside a table cell
\begin{tabular}{
@{}
l
S[table-format=6.0]
S[table-format=1.3]
S[table-format=2.2]
S[table-format=1.3]
S[table-format=2.3]
S[table-format=1.2,detect-weight]
S[table-format=1.3]
S[table-format=1.0]
S[table-format=2.2]
S[table-format=1.2]
S[table-format=1.3]
@{}
}
\toprule
\textbf{Instance} & {\bfseries Optimum} &
\multicolumn{3}{c}{\bfseries CNN} &
\multicolumn{3}{c}{\bfseries CNN-2-opt} &
\multicolumn{4}{c}{\bfseries PMSOM} \\
\cmidrule(lr){3-5} \cmidrule(lr){6-8} \cmidrule(l){9-12}
&& {\bfseries sec\textsuperscript{1}} & {\bfseries \%rozdíl} & {\bfseries TPDB} &
{\bfseries sec\textsuperscript{1}} & {\bfseries \%rozdíl} & {\bfseries TPDB} &
{\bfseries k*} & {\bfseries sec\textsuperscript{1}} & {\bfseries \%rozdíl\textsuperscript{2}} & {\bfseries TPDB} \\
eil51 & 426 & 0.019 & 18.78 & 0.004 & 0.019 & 4.23 & 0.001 & 1 & 0.31 & 1.64 & 0.005 \\
berlin52 & 7 542 & 0.088 & 8.49 & 0.007 & 0.019 & \bfseries 2.53 & 0.000 & 1 & 0.36 & 4.29 & 0.015 \\
eil76 & 538 & 0.110 & 13.94 & 0.015 & 0.042 & 7.25 & 0.003 & 1 & 0.67 & 3.72 & 0.025 \\
eil101 & 629 & 0.066 & 18.60 & 0.012 & 0.082 & 7.63 & 0.006 & 1 & 1.31 & 3.72 & 0.049 \\
lin105 & 14 379 & 0.231 & 17.80 & 0.041 & 0.094 & 5.30 & 0.005 & 1 & 1.11 & 3.00 & 0.033 \\
bier127 & 118 282 & 0.275 & 13.26 & 0.036 & 0.145 & 5.76 & 0.008 & 1 & 1.53 & 2.40 & 0.037 \\
ch130 & 6 110 & 0.269 & 17.82 & 0.048 & 0.190 & 5.09 & 0.010 & 2 & 4.53 & 2.39 & 0.108 \\
ch150 & 6 528 & 0.307 & 8.43 & 0.026 & 0.200 & \bfseries 2.79 & 0.006 & 2 & 3.01 & 3.30 & 0.099 \\
rat195 & 2 323 & 0.431 & 16.92 & 0.073 & 0.320 & 4.43 & 0.014 & 2 & 5.70 & 4.09 & 0.233 \\
d198 & 15 780 & 0.433 & 12.86 & 0.056 & 0.343 & 4.05 & 0.014 & 2 & 10.52 & 2.09 & 0.220 \\
pr299 & 48 191 & 0.873 & 20.95 & 0.183 & 1.362 & 6.02 & 0.082 & 2 & 7.81 & 3.99 & 0.312 \\
pcb442 & 50 778 & 2.093 & 16.10 & 0.337 & 2.621 & 6.06 & 0.159 & 2 & 11.13 & 5.54 & 0.617 \\
d493 & 35 002 & 2.431 & 18.56 & 0.451 & 5.017 & 5.49 & 0.275 & 3 & 19.52 & 4.55 & 0.889 \\
u574 & 36 905 & 3.506 & 20.62 & 0.723 & 7.651 & 7.83 & 0.599 & 3 & 30.51 & 3.94 & 1.201 \\
d657 & 48 912 & 4.950 & 23.63 & 1.170 & 12.671 & 6.62 & 0.839 & 3 & 22.22 & 4.32 & 0.960 \\
u724 & 41 910 & 6.410 & 21.94 & 1.406 & 13.839 & 5.77 & 0.798 & 3 & 21.41 & 5.30 & 1.136 \\
rat783 & 8 806 & 7.872 & 21.61 & 1.701 & 11.748 & 7.81 & 0.918 & 3 & 19.55 & 6.15 & 1.203 \\
\midrule
&&& 17.08 & 0.37 & & 5.57 & 0.22 & & & 3.79 & 0.42 \\
\midrule[\heavyrulewidth]
\multicolumn{12}{@{}l}{1) stanoveno jako průměr z 10 měření} \\
\multicolumn{12}{@{}l}{2) dle nejlepší hodnoty z 10 měření} \\
\end{tabular}
\end{sidewaystable}
\end{document}
答案2
使用\textsuperscript
命令:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\title{tabulka}
\author{petr102030 Hrobar}
\date{May 2019}
\begin{document}
\maketitle
\section{tabulka}
\begin{sidewaystable}[]
\caption{Instance do 1000 bodů}
\label{do1000}
\begin{tabular}{cccccccccccc}
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{3}{c}{\textbf{CNN}} & \multicolumn{3}{c}{\textbf{CNN-2-opt}} & \multicolumn{4}{c}{\textbf{PMSOM}} \\ \hline
\textbf{Instance} & \multicolumn{1}{c|}{\textbf{Optimum}} & \textbf{sec1} & \textbf{\%rozdíl} & \multicolumn{1}{c|}{\textbf{TPDB}} & \textbf{sec1} & \textbf{\%rozdíl} & \multicolumn{1}{c|}{\textbf{TPDB}} & \textbf{k*} & \textbf{sec \textsuperscript{1}} & \textbf{\%rozdíl2} & \textbf{TPDB} \\
eil51 & \multicolumn{1}{c|}{426} & 0.019 & 18.78 & \multicolumn{1}{c|}{0.004} & 0.019 & 4.23 & \multicolumn{1}{c|}{0.001} & 1 & 0.31 & 1.64 & 0.005 \\
berlin52 & \multicolumn{1}{c|}{7 542} & 0.088 & 8.49 & \multicolumn{1}{c|}{0.007} & 0.019 & \textbf{2.53} & \multicolumn{1}{c|}{0.000} & 1 & 0.36 & 4.29 & 0.015 \\
eil76 & \multicolumn{1}{c|}{538} & 0.110 & 13.94 & \multicolumn{1}{c|}{0.015} & 0.042 & 7.25 & \multicolumn{1}{c|}{0.003} & 1 & 0.67 & 3.72 & 0.025 \\
eil101 & \multicolumn{1}{c|}{629} & 0.066 & 18.60 & \multicolumn{1}{c|}{0.012} & 0.082 & 7.63 & \multicolumn{1}{c|}{0.006} & 1 & 1.31 & 3.72 & 0.049 \\
lin105 & \multicolumn{1}{c|}{14 379} & 0.231 & 17.80 & \multicolumn{1}{c|}{0.041} & 0.094 & 5.30 & \multicolumn{1}{c|}{0.005} & 1 & 1.11 & 3.00 & 0.033 \\
bier127 & \multicolumn{1}{c|}{118 282} & 0.275 & 13.26 & \multicolumn{1}{c|}{0.036} & 0.145 & 5.76 & \multicolumn{1}{c|}{0.008} & 1 & 1.53 & 2.40 & 0.037 \\
ch130 & \multicolumn{1}{c|}{6 110} & 0.269 & 17.82 & \multicolumn{1}{c|}{0.048} & 0.190 & 5.09 & \multicolumn{1}{c|}{0.010} & 2 & 4.53 & 2.39 & 0.108 \\
ch150 & \multicolumn{1}{c|}{6 528} & 0.307 & 8.43 & \multicolumn{1}{c|}{0.026} & 0.200 & \textbf{2.79} & \multicolumn{1}{c|}{0.006} & 2 & 3.01 & 3.30 & 0.099 \\
rat195 & \multicolumn{1}{c|}{2 323} & 0.431 & 16.92 & \multicolumn{1}{c|}{0.073} & 0.320 & 4.43 & \multicolumn{1}{c|}{0.014} & 2 & 5.70 & 4.09 & 0.233 \\
d198 & \multicolumn{1}{c|}{15 780} & 0.433 & 12.86 & \multicolumn{1}{c|}{0.056} & 0.343 & 4.05 & \multicolumn{1}{c|}{0.014} & 2 & 10.52 & 2.09 & 0.220 \\
pr299 & \multicolumn{1}{c|}{48 191} & 0.873 & 20.95 & \multicolumn{1}{c|}{0.183} & 1.362 & 6.02 & \multicolumn{1}{c|}{0.082} & 2 & 7.81 & 3.99 & 0.312 \\
pcb442 & \multicolumn{1}{c|}{50 778} & 2.093 & 16.10 & \multicolumn{1}{c|}{0.337} & 2.621 & 6.06 & \multicolumn{1}{c|}{0.159} & 2 & 11.13 & 5.54 & 0.617 \\
d493 & \multicolumn{1}{c|}{35 002} & 2.431 & 18.56 & \multicolumn{1}{c|}{0.451} & 5.017 & 5.49 & \multicolumn{1}{c|}{0.275} & 3 & 19.52 & 4.55 & 0.889 \\
u574 & \multicolumn{1}{c|}{36 905} & 3.506 & 20.62 & \multicolumn{1}{c|}{0.723} & 7.651 & 7.83 & \multicolumn{1}{c|}{0.599} & 3 & 30.51 & 3.94 & 1.201 \\
d657 & \multicolumn{1}{c|}{48 912} & 4.950 & 23.63 & \multicolumn{1}{c|}{1.170} & 12.671 & 6.62 & \multicolumn{1}{c|}{0.839} & 3 & 22.22 & 4.32 & 0.960 \\
u724 & \multicolumn{1}{c|}{41 910} & 6.410 & 21.94 & \multicolumn{1}{c|}{1.406} & 13.839 & 5.77 & \multicolumn{1}{c|}{0.798} & 3 & 21.41 & 5.30 & 1.136 \\
rat783 & \multicolumn{1}{c|}{8 806} & 7.872 & 21.61 & \multicolumn{1}{c|}{1.701} & 11.748 & 7.81 & \multicolumn{1}{c|}{0.918} & 3 & 19.55 & 6.15 & 1.203 \\ \hline
\multicolumn{3}{l}{1) stanoveno jako průměr z 10 měření} & 17.08 & \multicolumn{1}{c|}{0.37} & & 5.57 & \multicolumn{1}{c|}{0.22} & & & 3.79 & 0.42 \\
\multicolumn{3}{l}{2) dle nejlepší hodnoty z 10 měření} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\ \hline
\end{tabular}
\end{sidewaystable}
\end{document}