TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

in the MWE below, I wanted to be able to center the row entries vertically in the table. Thanks!

Here is my code:

\documentclass{book}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage[svgnames,table]{xcolor}

\begin{document}

\chapter*{List of Abbreviations}

\begin{center}
\rowcolors{2}{cyan!25}{white}
\begin{tabular}{ m{3cm} m{7cm} }
\rowcolor{cyan!50}
\arrayrulecolor{white}
\arrayrulewidth=1pt
\renewcommand{\arraystretch}{1.5}
\textbf{Abbreviation} & \textbf{Explanation} \\ [2ex]
\textbf{ACPR} & Adjacent Channel Power Rejection \\ [2ex]
\textbf{BER} & Bit Error Rate \\ [2ex]
\textbf{EVM} & Error Vector Magnitude \\ [2ex]
\textbf{FM} & Frequency Modulation \\ [2ex]
\textbf{HP} & High Port \\ [2ex]
\textbf{IMR} & Inter Modulation Rejection \\ [2ex]
\end{tabular}
\end{center}

\end{document}
share|improve this question
    
Do you expect multi line content of cells? – Zarko Feb 25 at 17:49
    
No, just single cell entries. Thanks. – Joe Feb 25 at 17:52
up vote 3 down vote accepted

Some suggestions:

  • Drop the [2ex] vertical spacing directives;

  • To compensate, increase \arraystretch to ca 1.75;

  • Use p rather than m column types; and

  • Omit the \arrayrulecolor{white} and \arrayrulewidth=1pt directives, as the code doesn't feature either horizontal or vertical lines.

enter image description here

\documentclass{book}
\usepackage[table]{xcolor}
\begin{document}

\begin{center}
\renewcommand{\arraystretch}{1.75}%
\rowcolors{2}{cyan!25}{white}
\begin{tabular}[t]{>{\bfseries}p{3cm} p{7cm}}
\rowcolor{cyan!50}
Abbreviation & Explanation \\ 
ACPR & Adjacent Channel Power Rejection \\ 
BER & Bit Error Rate \\ 
EVM & Error Vector Magnitude \\ 
FM & Frequency Modulation \\ 
HP & High Port \\ 
IMR & Inter Modulation Rejection \\ 
\end{tabular}
\end{center}

\end{document}

Addendum to address the OP's follow-up query: To have a thick white line separate the two header cells, add the instructions \arrayrulecolor{white} and \setlength{\arrayrulewidth}{2pt} before \begin{tabular} and change the first header cell from Abbreviation to \multicolumn{1}{l|}{\bfseries Abbreviation}.

share|improve this answer
    
@Micro, Thanks for your solution! Is there a way to add a thick white line to separate the Abbreviation and Explanation? Thanks again! – Joe Feb 25 at 17:54
1  
@joe - I've provided an addendum to my answer to address your follow-up query. – Mico Feb 25 at 18:05
    
Sorry, I may have "mis-wrote"...how to place that thick white line all the way vertically down the table and not just the first row? Thanks again! – Joe Feb 25 at 22:44
1  
@Joe - Just change \begin{tabular}[t]{>{\bfseries}p{3cm} p{7cm}} to \begin{tabular}[t]{>{\bfseries}p{3cm} | p{7cm}}, after (of course) executing \arrayrulecolor{white} and \setlength{\arrayrulewidth}{2pt}. – Mico Feb 25 at 23:01

Huh, @Mico was few second faster than me with almost the same solution, so I change mine slightly.

Edit: Since after upload of my answer, I reed your comment, that the cells wiuld be only with one line content, I reduce my solution to use p{...} type of columns. For better vertical aligning I also ad small trick with rule[...]{...}{...} and erase \arraystretch, see the code below:

\documentclass{book}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage[svgnames,table]{xcolor}

\begin{document}
\chapter*{List of Abbreviations}
    \begin{center}
    \rowcolors{2}{cyan!25}{white}
\begin{tabular}{@{\hspace{\tabcolsep}\rule[-2.2ex]{0pt}{6ex}} >{\bfseries}p{3cm} p{7cm} }
\rowcolor{cyan!50}
Abbreviation    
                & \textbf{Explanation}              \\ 
ACPR            & Adjacent Channel Power Rejection  \\
BER             & Bit Error Rate                    \\
EVM             & Error Vector Magnitude            \\
FM              & Frequency Modulation              \\
HP              & High Port                         \\
IMR             & Inter Modulation Rejection        \\
\end{tabular}
    \end{center}
\end{document}

enter image description here

share|improve this answer
2  
The typographic struts of height 6ex and depth 2.5ex may center the text mathematically, but not optically/aesthetically. (The eye wants to "see" a bit more space above the ascenders than below the descenders to achieve visual centering.) I'd increase the height of the struts and/or decrease the depth of the struts slightly. The struts seem to dominate the effect of setting \arraystretch to 1.5; omit that instruction? – Mico Feb 25 at 18:11
2  
Mico, meantime I adjust used strut a bit. To be honest, its use is introduced that my answer differ a bit from yours, however after some tweaking of strut size in my ayes it provide better optical centering than is obtained by array stretch. Probably I'm wrong (my ayes recently are so tired ... ) – Zarko Feb 25 at 20:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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