6

first-time poster here. I've been beating my head against the wall for the past few hours trying to figure out how to display the table below the way I want it. I've gotten pretty close, but there are a few minor details that I can't seem to get right, and I was hoping someone here could help me out. Here's the table:

enter image description here

As you may guess from the markings I've made on the image, I'd like to

  1. Remove the lines crossed out in orange.
  2. Move the text circled in green to the exact center of the cell.
  3. All the cells circled in purple are horizontally centered. I would also like them to be vertically centered, but the n+1 methods I've tried haven't been successful.
  4. Vertically center the multiple cells circled in red.

I've tried using m{width} to fix the alignment issues, but I haven't been successful.

I am certainly no LaTeX expert, so my code may look a bit amateur and unorganized, but here it is (hopefully I haven't forgotten the relevant packages):

\usepackage{bm}
\usepackage{array}

\begin{table}[h]
\begin{center}
\begin{tabular}{|m{0.75cm} m{0.75cm}| *{11}{ >{\centering\arraybackslash} m{1.25cm}|}}
\cline{1-13}
    
    & & \multicolumn{11}{||c||}{\textbf{ Initial Orbital Period (days) }} \\ \cline{3-13}
    & & \textbf{5} & \textbf{10} & \textbf{20} & \textbf{30} & \textbf{60} & \textbf{100} & \textbf{170} & \textbf{300} & \textbf{500} & \textbf{750} & \textbf{1000} \\ \cline{1-13}
    \multicolumn{1}{ |m{0.75cm} }{\multirow{6}{1.5em}{\rotatebox[origin=c]{90}{ \textbf{Initial Accretor Mass ( }$\bm{M}_{\odot}$\textbf{)}}}} & 
    \multicolumn{1}{ |m{0.75cm}| }{$\bm{0.90}$} & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\[5ex] \cline{2-13} &
    
    \multicolumn{1}{ |m{0.75cm}| }{$\bm{0.95}$} & x/\checkmark/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ [5ex]
    \cline{2-13} &
    
    \multicolumn{1}{ |m{0.75cm}| }{$\bm{1.00}$} & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\[5ex] \cline{2-13} &
    
    \multicolumn{1}{ |m{0.75cm}| }{$\bm{1.05}$} & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\[5ex] \cline{2-13} &
    
    \multicolumn{1}{ |m{0.75cm}| }{$\bm{1.10}$} & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\[5ex] \cline{2-13} &
    
    \multicolumn{1}{ |m{0.75cm}| }{$\bm{1.15}$} & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\[5ex] \cline{1-13}
    
\end{tabular}
\caption{Test}
\label{tab:tab1}
\end{center}
\end{table}

I know that if I change the first \cline{1-13 to \cline{3-13}, the horizontal line that I've crossed out in orange will disappear. Also, changing

\begin{tabular}{|m{0.75cm} m{0.75cm}| *{11}{ >{\centering\arraybackslash} m{1.25cm}|}}

to

\begin{tabular}{m{0.75cm} m{0.75cm}| *{11}{ >{\centering\arraybackslash} m{1.25cm}|}}

will remove the vertical line I've crossed out in orange (I've removed the first pipe). However, this creates an even worse issue that I equally do not know how to solve (the majority of the left vertical line is removed):

enter image description here

Any help here would be greatly appreciated!!

EDIT: I've made some progress. I've managed to figure out how to remove the lines crossed out in orange above. All the other issues still remain, however, and I'm still having trouble figuring them out. Here's the new code for reference:

\begin{table}[h]
\begin{tabular}{m{0.75cm} m{0.75cm} | *{11}{>{\centering\arraybackslash} m{1.0cm}|}}
\cline{3-13}
\multicolumn{1}{l}{} & \multicolumn{1}{l|}{} & \multicolumn{11}{c|}{\textbf{Initial Orbital Period (days)}} \\ \cline{3-13} 
\multicolumn{1}{l}{} & \multicolumn{1}{l|}{} & \textbf{5} & \textbf{10} & \textbf{20} & \textbf{30} & \textbf{60} & \textbf{100} & \textbf{170} & \textbf{300} & \textbf{500} & \textbf{750} & \textbf{1000} \\ \hline
\multicolumn{1}{|m{0.5cm}|}{\multirow{6}{*}{\rotatebox[origin=c]{90}{\textbf{Initial Accretor Mass (}\bm{$M_{\odot}$}\textbf{)}}}} & \textbf{0.90} & x/\checkmark/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\[5ex] \cline{2-13}
\multicolumn{1}{|c|}{} & \textbf{0.95} &  &  &  &  &  &  &  &  &  &  &  \\[5ex] \cline{2-13} 
\multicolumn{1}{|c|}{} & \textbf{1.00} &  &  &  &  &  &  &  &  &  &  &  \\[5ex] \cline{2-13} 
\multicolumn{1}{|c|}{} & \textbf{1.05} &  &  &  &  &  &  &  &  &  &  &  \\[5ex] \cline{2-13} 
\multicolumn{1}{|c|}{} & \textbf{1.10} &  &  &  &  &  &  &  &  &  &  &  \\[5ex] \cline{2-13} 
\multicolumn{1}{|c|}{} & \textbf{1.15} &  &  &  &  &  &  &  &  &  &  &  \\[5ex] \hline
\end{tabular}
\end{table}

...and here's what the new table looks like:

enter image description here

7

I propose this code, with cellspace, which ensures a minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S by default (or whatever letter you please with the optional argument [column=some letter]:

\documentclass{article}
\usepackage{geometry}
\usepackage{bm, dingbat}
\usepackage{array, multirow, cellspace}
\setlength{\cellspacetoplimit}{2ex}
\setlength{\cellspacebottomlimit}{2ex}
\usepackage{rotating}

\begin{document}

\begin{table}[!h]
\centering \small \setlength{\tabcolsep}{3pt}
\begin{tabular}{|m{0.75cm}|>{\centering\arraybackslash}S{m{0.75cm}}| >{\centering\arraybackslash}S{m{1.3cm}}|*{10}{>{\centering\arraybackslash}S{m{1cm}}|}}
\cline{3-13}
   \multicolumn{2}{c}{} & \multicolumn{11}{||Sc||}{\textbf{ Initial Orbital Period (days) }} \\ \cline{3-13}
   \multicolumn{2}{c|}{} & \textbf{5} & \textbf{10} & \textbf{20} & \textbf{30} & \textbf{60} & \textbf{100} & \textbf{170} & \textbf{300} & \textbf{500} & \textbf{750} & \textbf{1000} \\ \cline{1-13}
   \multirow{6}{=}[-4.2ex]{\centering\rotatebox[origin=c]{90}{ \textbf{Initial Accretor Mass ( }$\bm{M}_{\odot}$\textbf{)}}} &
   $\bm{0.90}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \cline{2-13}
    & $\bm{0.95}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \cline{2-13}
    & $\bm{1.00}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \cline{2-13}
    & $\bm{1.05}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \cline{2-13}
    & $\bm{1.10}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \cline{2-13}
    & $\bm{1.15}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ \cline{1-13}
\end{tabular}
\caption{Test}
\label{tab:tab1}
\end{table}

\end{document} 

enter image description here

4
  • This achieves what I wanted spot-on! However, this seems to clash with the document class I'm using (\documentclass[twocolumn]{aastex63}). The table isn't compiling correctly for some reason, and the geometry package messes up the formatting of my paper quite a bit. Your code works like a charm if I use \documentclass{article}, however. Might you know what's going on here?
    – david99
    Apr 26 at 23:51
  • @david99: I added geometry because for the standard classes, the table was a bit too wide for the margins, depite I reduced the font size and the value of \tabcolsep. As to the problem with you document class, could you explain what the log says? Maybe it is linked to the fact that you're in two-column mode? In this case, a possible solution would be to use the strip environment, from the cuted package (sttools bundle), which uses temporarily one-column mode.
    – Bernard
    Apr 27 at 9:12
  • Is it just me or are the check marks (ticks) a little too high relative to the x’s?
    – Anush
    Apr 30 at 8:52
  • No, you're right. I think the design of the font places the glyphs a bit above the base line. You can define a macro with a negative \raisebox (probably something between -0.5 and -1 ex) to have them aligned on the base line.
    – Bernard
    Apr 30 at 9:30
6

With {NiceTabular} of nicematrix.

In {NiceTabular}, you merge cells both horizontally and vertically with the command \Block. For the rows, you give the number of logical rows (and not the number of physical lines as with \multicolumn).

You specify that you want a corner with corners=NW (north west).

With the key hvlines, all the rules are drawn, excepted in the blocks (constructed by \Block) and in the corners (specified by corners).

\documentclass{article}
\usepackage{bm}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage{nicematrix}

\begin{document}

\begin{sidewaystable}[h]
\small
\begin{center}
\renewcommand{\arraystretch}{2}
\begin{NiceTabular}{w{c}{0.75cm}>{\bfseries}w{c}{0.75cm}*{11}{w{c}{1.25cm}}}[corners=NW,hvlines]
& & \Block{1-*}{\bfseries Initial Orbital Period (days)} \\ 
& & \RowStyle{\bfseries} 5 & 10 & 20 & 30 & 60 & 100 & 170 & 300 & 500 & 750 & 1000 \\ 
\Block{6-1}{\rotate \bfseries Initial Accretor Mass ($\bm{M}_{\odot}$)} 
& 0.90 & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\  
& 0.95 & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\  
& 1.00 & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\  
& 1.05 & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\  
& 1.10 & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\  
& 1.15 & x/ \checkmark / \checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ 
\end{NiceTabular}
\caption{Test}
\label{tab:tab1}
\end{center}
\end{sidewaystable}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

3

This is Bernard's solution after reading booktabs

\documentclass{article}
\usepackage{geometry}
\usepackage{bm, dingbat}
\usepackage{array, multirow, cellspace, booktabs}
\setlength{\cellspacetoplimit}{2ex}
\setlength{\cellspacebottomlimit}{2ex}
\usepackage{rotating}

\begin{document}

\begin{table}[!h]
\centering \small \setlength{\tabcolsep}{3pt}
\begin{tabular}{m{0.75cm}>{\centering\arraybackslash}S{m{0.75cm}}>{\centering\arraybackslash}S{m{1.3cm}}*{10}{>{\centering\arraybackslash}S{m{1cm}}}}
\toprule
   \multicolumn{2}{c}{} & \multicolumn{11}{Sc}{\textbf{ Initial Orbital Period (days) }} \\ 
   \cmidrule{3-13}
   \multicolumn{2}{c}{} & \textbf{5} & \textbf{10} & \textbf{20} & \textbf{30} & \textbf{60} & \textbf{100} & \textbf{170} & \textbf{300} & \textbf{500} & \textbf{750} & \textbf{1000} \\ 
   \cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(lr){5-5}\cmidrule(lr){6-6}\cmidrule(lr){7-7}\cmidrule(lr){8-8}\cmidrule(lr){9-9}\cmidrule(lr){10-10}\cmidrule(lr){11-11}\cmidrule(l){12-12}\cmidrule(lr){13-13}
   \multirow{6}{=}[-4.2ex]{\centering\rotatebox[origin=c]{90}{ \textbf{Initial Accretor Mass ( }$\bm{M}_{\odot}$\textbf{)}}} &
   $\bm{0.90}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ 
    & $\bm{0.95}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\
    & $\bm{1.00}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\
    & $\bm{1.05}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\
    & $\bm{1.10}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ 
    & $\bm{1.15}$ & x/\checkmark\!/\checkmark & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ 
    \bottomrule
\end{tabular}
\caption{Test}
\label{tab:tab1}
\end{table}

\end{document} 

enter image description here

0

While all this answers are very good, I also recommend you to look at the tables generator in https://www.tablesgenerator.com It is very very good and can help you to get that table in no time. It has plenty of tools to centre the row/columns entries. My experience is that using that tool, you can finish that table quickly and easily.

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.