# How do I vertically align all entries in a relatively complicated table?

I'm relatively new to Latex, but found it pretty useful in writing up my thesis. However, I'm having trouble with a slightly complicated table and how the it is presenting itself after running. I used a table generator to spit out something similar to what I wanted. The table looks decent, but the vertical alignment is causing some superscripts I have to be cut into a couple of horizontal lines. I've been reading about solutions for vertical centering, but I'll be frank, a lot of it is confusing and hasn't worked (possibly due to my own incompetence). What would be the proper way to format the table so I have perfectly centered entries?

\documentclass{thesis}
\usepackage{float}
\usepackage{latexsym}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{pdfpages}
\usepackage{leftidx}
\usepackage{array}

\begin{document}
\begin{table}[h]
\centering
\caption{ABC}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multicolumn{5}{|c|}{{\textit{\textbf{Raman Shifts (cm$^{-1}$)}}}}                                                                                                                                                                                                                \\ \hline
\multicolumn{1}{|c|}{\multirow{2}{*}{\textbf{Vibrational Mode}}} & \multicolumn{2}{c|}{\textbf{ $\leftidx{^{Z}}{X}{_Y}$ Theoretical}}                                                         & \multicolumn{2}{c|}{\textbf{ $\leftidx{^{Z}}{X}{_Y}$ Measured}}                                                            \\ \cline{2-5}
\multicolumn{1}{|c|}{}                                           & \multicolumn{1}{c|}{\textit{\textbf{Single Sub.}}} & \multicolumn{1}{c|}{\textit{\textbf{Double Sub.}}} & \multicolumn{1}{c|}{\textit{\textbf{Single Sub.}}} & \multicolumn{1}{c|}{\textit{\textbf{Double Sub.}}} \\ \hline
\textbf{$\nu$ (M=X)}                                              & X                                               & X                                               & X                                               & X                                               \\ \hline
\textbf{$\nu_{s}$ (X=M=X)}                                           & X                                               & X                                               & X                                               & X                                               \\ \hline
\textbf{$\nu_{as}$ (X=M=X)}                                          & X                                               & X                                               & X                                               & X                                               \\ \hline
\textbf{$\nu_{as}$ (M-X-M)}                                         & X                                               & X                                               & X                                               & X                                               \\ \hline
\textbf{$\delta$ (M-X)}                                              & X                                               & X                                               & X                                               & X                                               \\ \hline
\end{tabular}
\end{table}
\end{document}


• I'd suggest going for a slightly different layout by removing all vertical lines and most of the horizontal lines. For horizontal lines with a decent amount of white space around them, I'd recommend the lines from the booktabs package. – leandriis Oct 3 '19 at 21:30
• How or where is \leftidx defined? – Mico Oct 3 '19 at 21:32
• Sorry, I forgot to put the preamble stuff in the codeblock, and editing it is provin to more of a headache. \leftidx was from a package to make it easier to have superscripts for the left side of elements. – Ben Ruiz Oct 3 '19 at 21:44
• @Mico: \leftidx is defined in the homonymous package. Very useful for the transpose of a matrix (better than \prescript from mathtools, in my opinion). – Bernard Oct 3 '19 at 22:14

Alas, tabular environments generated by table-generator programs tend to have all the attractiveness and charm of prison-cell windows, with lots of vertical and horizontal bars literally obstructing the reader's eye from entering into the table.

I second @leandriis' suggestion to give the table a much more open look, by omitting all vertical rules and most horizontal rules. For the few essential horizontal lines, use the line-drawing macros of the booktabs package.

I further believe that no compelling purpose is served by overusing (really: abusing) bold and *bold italics in header cells. For sure, your table works just fine -- actually, even better -- if the header cells are rendered in the plain font.

\documentclass{article}
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{siunitx}  % for '\si' macro
\usepackage[skip=0.333\baselineskip]{caption} % optional
\providecommand\leftidx[3]{{}^{#1\mkern-4mu}#2_{\mkern-2mu#3}} %% is this ok??

\begin{document}
\begin{table}[h]
\setlength\tabcolsep{0pt} % make LaTeX figure out optimal intercol. whitespace amount
\caption{ABC}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lcccc}
\toprule
Vibrational Mode & \multicolumn{4}{c}{Raman Shifts (\si{\per\centi\meter}) } \\
\cmidrule{2-5}
& \multicolumn{2}{c}{$\leftidx{Z}{X}{Y}$ Theoretical}
& \multicolumn{2}{c}{$\leftidx{Z}{X}{Y}$ Measured} \\
\cmidrule{2-3} \cmidrule{4-5}
& Single Sub. & Double Sub. & Single Sub. & Double Sub. \\
\midrule
$\nu$ $(M=X)$        & X & X & X & X \\
$\nu_{s}$ $(X=M=X)$  & X & X & X & X \\
$\nu_{as}$ $(X=M=X)$ & X & X & X & X \\
$\nu_{as}$ $(M-X-M)$ & X & X & X & X \\
$\delta$ $(M-X)$     & X & X & X & X \\