使用 Latex 改进此表

使用 Latex 改进此表
\documentclass[12pt,a4paper]{report}

\begin{document}
\begin{center}
 \begin{tabular}{|c|c|c|c|c|}
\hline 
{Après-midi}\hspace{1cm}&\hspace{1cm}{Matin} & \hspace{1cm}   \\
\hline
{\small
\begin{tabular}{c|c|c}
x & y & z
 \\
 \hline
19h25 & 12h56 & 41
\\
\hline
20h32 & 14h00 & 37
\\
\hline
21h43 & 15h13 & 38
\\
\hline
22h48 & 16h23 & 43
\\
\hline
23h51 & 17h20 & 51
\\
\hline
22h48 & 16h23 & 59
\\
\hline
22h48 & 16h23 & 67
\\
\hline
 \end{tabular} }
& {\small
\begin{tabular}{c|c|c}
x & y & z
 \\
 \hline
6h56 & 0h35 & 45 
\\
\hline
7h56 & 1h33 & 38
\\
\hline
9h08 & 2h42 & 36
\\
\hline
10h19 & 3h54 & 40
\\
\hline
20h32 & 14h00 & 47
\\
\hline
-- & 14h00 & 55
\\
\hline
0h25 & 6h25 & 63
\\
\hline
\end{tabular}}
& 1
\end{tabular}
\end{center}
\end{document}

在此处输入图片描述

除了 41,37,我还想得到 1,2,3,4,5,6,7......但我只得到 1?

答案1

我同意关于嵌套表格的评论,但我保留了那部分不变。也许这就是你想要的?如果你只需要最后一列的编号,那么你需要从“Après-midi”列中删除列规范T(以及所有最后的&s)。我使用了\thead非常有用的makecell包中的宏来允许在居中的列标题中进行换行

\documentclass[12pt,a4paper]{report}
\usepackage{array}
\usepackage{makecell}
\usepackage{etoolbox}
\newcounter{tcount}
\newcolumntype{T}{>{\stepcounter{tcount}\thetcount}c}
\AtBeginEnvironment{tabular}{\setcounter{tcount}{0}}
\begin{document}
\begin{center}
 \begin{tabular}{|c|c|c|c|}
\hline 
\thead{Après-midi\\Afternoon}&\thead{Matin\\Morning}    \\
\hline
{\small
\begin{tabular}{c|c|c|T}
x & y & z &\multicolumn{1}{c}{}
 \\
 \hline
19h25 & 12h56 & 41 &
\\
\hline
20h32 & 14h00 & 37 &
\\
\hline
21h43 & 15h13 & 38  &
\\
\hline
22h48 & 16h23 & 43 &
\\
\hline
23h51 & 17h20 & 51 &
\\
\hline
22h48 & 16h23 & 59 &
\\
\hline
22h48 & 16h23 & 67 &
 \end{tabular} }
& {\small
\begin{tabular}{c|c|c|T}
x & y & z & \multicolumn{1}{c}{}
 \\
 \hline
6h56 & 0h35 & 45  &
\\
\hline
7h56 & 1h33 & 38  &
\\
\hline
9h08 & 2h42 & 36 &
\\
\hline
10h19 & 3h54 & 40 &
\\
\hline
20h32 & 14h00 & 47 &
\\
\hline
-- & 14h00 & 55 &
\\
\hline
0h25 & 6h25 & 63 &
\end{tabular}}
\\
\hline
\end{tabular}
\end{center}
\end{document}

代码输出

相关内容