表格中各列的宽度不一致

表格中各列的宽度不一致

下表中“塔”行的长度不等。你们能否建议我如何将列精确地划分在中心?

\begin{landscape}
\begin{table}{Variable Timeslots}
\centering
\caption{Observe that the length of one timeslot here is 30 min. Attractions "Tower" takes one timeslot whereas other attractions take two timeslots to complete.}
\label{tab:VariableTimeslot}
    \begin{tabular}{ | c | c | p{0.5cm} | c | c | c | c | c | c | c | c | c | c | c |}
    \hline 
    TIME & \multicolumn{2}{|c|}{09:00-10:00} & \multicolumn{2}{|c|}{10:00-11:00} & \multicolumn{2}{|c|}{11:00-12:00} & \multicolumn{2}{|c|}{13:00-14:00} & \multicolumn{2}{|c|}{14:00-15:00} & \multicolumn{2}{|c|}{15:00-16:00} \\ 
    \hline  \centering TIMESLOT & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
    \hline  PAVILION TOUR (10) & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} \\ 
    \hline TOWER (12) & & & & & & & & & & & & \\ 
    \hline  GIANT WHEEL (40) & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} &\multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} \\
    \hline  WATER RIDE (40) & \multicolumn{2}{|c|}{}& \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} &  \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} \\
    \hline  TRAIN RIDE (30) & \multicolumn{2}{|c|}{}& \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{}  & \multicolumn{2}{|c|}{}&\multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{}\\ 
    \hline 
    \end{tabular}
\end{table}
\end{landscape}

答案1

您的所有想法\multicolumn{2}{|c|}...都是错的,它们应该是\multicolumn{2}{c|}...。此外,使用固定宽度的列可以避免您的问题,>{\centering\arraybackslash}并向p列中添加居中内容。

\documentclass{article}

\usepackage{array,pdflscape}


\begin{document}
\begin{landscape}
\begin{table}
\centering
Variable Timeslots
\caption{Observe that the length of one timeslot here is 30 min. Attractions "Tower" takes one timeslot whereas other attractions take two timeslots to complete.}
\label{tab:VariableTimeslot}
    \begin{tabular}{ | c | *{12}{>{\centering\arraybackslash}p{0.8cm} |}}
    \hline
    TIME & \multicolumn{2}{c|}{09:00-10:00} & \multicolumn{2}{c|}{10:00-11:00} & \multicolumn{2}{c|}{11:00-12:00} & \multicolumn{2}{c|}{13:00-14:00} & \multicolumn{2}{c|}{14:00-15:00} & \multicolumn{2}{c|}{15:00-16:00} \\
    \hline  TIMESLOT & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
    \hline  PAVILION TOUR (10) & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\
    \hline TOWER (12) & & & & & & & & & & & & \\
    \hline  GIANT WHEEL (40) & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\
    \hline  WATER RIDE (40) & \multicolumn{2}{c|}{}& \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &  \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\
    \hline  TRAIN RIDE (30) & \multicolumn{2}{c|}{}& \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{}  & \multicolumn{2}{c|}{}&\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{}\\
    \hline
    \end{tabular}
\end{table}
\end{landscape}
\end{document} 

在此处输入图片描述

顺便说一句,table环境不接受任何强制性参数。

答案2

tabularx带有以下包的解决方案caption

\documentclass[12pt,leqno]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{tabularx, caption}
\usepackage{lscape}

\begin{document}
\begin{landscape}
    \begin{table}%
    \captionsetup{justification = centerfirst}
    \caption{Variable Timeslots \smallskip\\\footnotesize
    Observe that the length of one timeslot here is 30 min. Attractions "Tower" takes one timeslot whereas other attractions take two timeslots to complete.}
    \label{tab:VariableTimeslot}
    \begin{tabularx}{\linewidth}{ | c | *{12}{>{\centering\arraybackslash}X|}}
        \hline
        TIME & \multicolumn{2}{|c|}{09:00--10:00} & \multicolumn{2}{|c|}{10:00--11:00} & \multicolumn{2}{|c|}{11:00--12:00} & \multicolumn{2}{|c|}{13:00--14:00} & \multicolumn{2}{|c|}{14:00--15:00} & \multicolumn{2}{|c|}{15:00--16:00} \\
        \hline \centering TIMESLOT & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
        \hline PAVILION TOUR (10) & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} \\
      \hline TOWER (12) & & & & & & & & & & & & \\
        \hline GIANT WHEEL (40) & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} &\multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} \\
        \hline WATER RIDE (40) & \multicolumn{2}{|c|}{}& \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} \\
        \hline TRAIN RIDE (30) & \multicolumn{2}{|c|}{}& \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{}&\multicolumn{2}{|c|}{} & \multicolumn{2}{|c|}{}\\
        \hline
    \end{tabularx}
    \end{table}
\end{landscape}
\end{document} 

在此处输入图片描述

答案3

具有中心列的解决方案m

% arara: pdflatex

\documentclass{article}
\usepackage{lscape}
\usepackage{caption}
\usepackage{calc}
\usepackage{csquotes}
\usepackage{siunitx}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newlength{\mylength}

\begin{document}
\setlength{\mylength}{\widthof{09:00-10:00}+1.5\columnsep}
\begin{landscape}
    \begin{table}
        \centering
        \caption{Observe that the length of one timeslot here is \SI{30}{\min}. Attractions \enquote{Tower} takes one timeslot whereas other attractions take two timeslots to complete.}
        \label{tab:VariableTimeslot}
        \begin{tabular}{ | l | *{13}{@{}C{.5\mylength}@{}|}}
            \hline 
            TIME & \multicolumn{2}{c|}{09:00-10:00} & \multicolumn{2}{c|}{10:00-11:00} & \multicolumn{2}{c|}{11:00-12:00} & \multicolumn{2}{c|}{13:00-14:00} & \multicolumn{2}{c|}{14:00-15:00} & \multicolumn{2}{c|}{15:00-16:00} \\ 
            \hline  
            TIMESLOT & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
            \hline  PAVILION TOUR (10) & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\ 
            \hline TOWER (12) & & & & & & & & & & & & \\ 
            \hline  GIANT WHEEL (40) & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\
            \hline  WATER RIDE (40) & \multicolumn{2}{c|}{}& \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} &  \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} \\
            \hline  TRAIN RIDE (30) & \multicolumn{2}{c|}{}& \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{}  & \multicolumn{2}{c|}{}&\multicolumn{2}{c|}{} & \multicolumn{2}{c|}{}\\ 
            \hline 
        \end{tabular}
    \end{table}
\end{landscape}
\end{document}

在此处输入图片描述

答案4

这里有一个例子,教你如何使用普通 TeX 创建此表,而无需 LaTeX 的复杂处理:

\vbox{\offinterlineskip
   \def\crl{\crcr\noalign{\hrule}}
   \def\rl{\hfil\vrule\hfil\null} \def\nn{&&&&&&} \def\ce#1{\hbox to0pt{\hss#1\hss}}
   \halign{\vrule height12pt depth5pt\hfil\ #\unskip\ \hfil\vrule
           &&\hfil\ #\unskip\ \hfil\vrule\cr\crl
      TIME & 09:00--10:00 & 10:00--11:00 & 11:00--12:00 & 
             13:00--14:00 & 14:00--15:00 & 15:00--16:00 \crl
      TIMESLOT          & 1\rl2 & 3\rl4 & 5\rl6 & 7\rl8 & \ce9\rl\ce{10} & 11\rl12 \crl
      PAVILON TOUR (10) \nn \crl
      TOWER (12)        & \rl & \rl & \rl & \rl & \rl & \rl \crl
      GIANT WHEEL (40)  \nn \crl
      WATER RIDE (40)   \nn \crl
      TRAIN RIDE (30)   \nn \crl
}}

相关内容