3

How can I adjust the vertical alignment in the following table for the cell which have for example the value \{0.91,0.15\}:

\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\begin{table}[h]
\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule[1.5pt]
\multirow{2}{*}{days} & \multicolumn{4}{c}{Time in \{Min,Sec\}} \\ \cmidrule[1.5pt](){2-5}
      & D         & M     & A    & N     \\ \hline
6                         & \{5,15\}     &         &         &         \\ \hline
6                         &      \{0.91,0.15\}       &         &         &         \\ \hline
6                         &     \{99,0.5\}      &         &    \{77,22\}       &         \\ \hline
6                         &             &         &    \{0.31,0.15\}     &         \\ \hline
\end{tabular}
\end{table}

2 Answers 2

2

The spacing issue seems to apply to just about all the rows in the table, so I would suggest you set \arraystretch to say 1.2 to widen the spacing between rows. You can do this via

\renewcommand{\arraystretch}{1.2}

Putting this command inside the table environment will make it local to that environment.

Had this been a one off, then you could have inserted a rule of zero width and appropriate height and depth to force the lines apart by writing the entry as

\vrule width 0pt height 12pt depth 5pt \{0.91,0.15\}

for example.

Here is the \arraystretch version:

Sample output

\documentclass{article}

\usepackage{multirow,array,booktabs}

\begin{document}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\begin{table}[h]\renewcommand{\arraystretch}{1.2}
\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule[1.5pt]
\multirow{2}{*}{days} & \multicolumn{4}{c}{Time in \{Min,Sec\}} \\ \cmidrule[1.5pt](){2-5}
      & D         & M     & A    & N     \\ \hline
6                         & \{5,15\}     &         &         &         \\ \hline
6                         &      \{0.91,0.15\}       &         &         &         \\ \hline
6                         &     \{99,0.5\}      &         &    \{77,22\}       &         \\ \hline
6                         &             &         &    \{0.31,0.15\}     &         \\ \hline
\end{tabular}
\end{table}
\end{document}
1

Use the booktabs rules, not \hline; however, avoiding too many rules is better; I'll present two realizations of the table.

\documentclass{article}

\usepackage{array,booktabs}

\begin{document}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\begin{table}[htp]

\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule
days & \multicolumn{4}{c}{Time in \{Min,\,Sec\}} \\ 
\cmidrule(lr){2-5}
   & D               & M       & A               & N  \\
\midrule
6  & \{5,\,15\}      &         &                 &    \\
6  & \{0.91,\,0.15\} &         &                 &    \\
6  & \{99,\,0.5\}    &         & \{77,\,22\}     &    \\
6  &                 &         & \{0.31,\,0.15\} &    \\
\bottomrule
\end{tabular}

\bigskip

\begin{tabular}{c C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule
days & \multicolumn{4}{c}{Time in \{Min,\,Sec\}} \\ 
\cmidrule(lr){2-5}
   & D               & M       & A               & N  \\
\midrule
6  & \{5,\,15\}      &         &                 &    \\
\midrule
6  & \{0.91,\,0.15\} &         &                 &    \\
\midrule
6  & \{99,\,0.5\}    &         & \{77,\,22\}     &    \\
\midrule
6  &                 &         & \{0.31,\,0.15\} &    \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.