# Vertical center alignment of text in cell of table

I am trying to create following table But the problem is that the big round brackets in third column are sitting on the horizontal lines. Is there some way to center align the brackets vertically in an easy manner?

\begin{tabular}{ |c | c | c|}

\hline
\rowcolor{myblue} \textcolor{white}{Parabola} & \textcolor{white}{Equation of Tangent} & \textcolor{white}{Point of Contact} \\

\rule{0pt}{25pt}\bm{$y^2=4ax$} & \bm{$\displaystyle y=mx+\frac{a}{m}$} & \bm{$\displaystyle \bigg(\frac{a}{m^2},\frac{2a}{m}\bigg)$}   \\ \hline

\rule{0pt}{25pt}\bm{$y^2=-4ax$} & \bm{$\displaystyle y=mx-\frac{a}{m}$} & \bm{$\displaystyle \bigg(-\frac{a}{m^2},\frac{2a}{m}\bigg)$}   \\  \hline

\rule{0pt}{20pt}\bm{$x^2=4ay$} & \bm{$\displaystyle y=mx-am^2$} & \bm{$\displaystyle \big(2am,am^2\big)$}   \\ \hline

\rule{0pt}{20pt}\bm{$x^2=-4ay$} & \bm{$\displaystyle y=mx+am^2$} & \bm{$\displaystyle \big(-2am,-am^2\big)$}   \\   \hline

\end{tabular}

• Take a look as the cellspace package Aug 24, 2020 at 18:36
• wow I wrote \bm and I would never have guessed it worked outside math mode. It would be far more efficient to use \boldmath $x$ than \bm{$x$} Aug 24, 2020 at 19:59
• @DavidCarlisle Why is that? I am a beginner in latex so can't figure out the reason. Aug 24, 2020 at 20:03
• \bm is intended to make individual subterms in a larger expression bold, so it is intended to be used in math not around it. making the whole expression bold is much easier and has always been supported by core latex with no packages at all with \boldmath. \boldmath is just a simple font switch , \bm has to deconstruct every symbol and reconstitute an equivalent math expression using the bold version of each symbol. Aug 24, 2020 at 20:06
• Similar to stackoverflow.com/questions/57775397/… Jan 4, 2021 at 14:24

I suggest to use {NiceTabular} of nicematrix which provides parameters cell-space-bottom-limit and cell-space-top-limit inspired by the lengths \cellspacebottomlimit and \cellspacetoplimit of the package cellspace.

{NiceTabular} is designed to give better results than standard colortbl in the PDF viewers when rules are used in conjonction with colored panels. However, you need several compilations.

\documentclass{article}

\usepackage{nicematrix}

\begin{document}
\begin{center}
\everymath{\displaystyle}
\NiceMatrixOptions{cell-space-top-limit=2pt,cell-space-bottom-limit=2pt}
\begin{NiceTabular}{ccc}[hvlines,colortbl-like]
\rowcolor{blue!50} \textcolor{white}{Parabola} & \textcolor{white}{Equation of Tangent} & \textcolor{white}{Point of Contact} \\
$y^2=4ax$& $y=mx+\frac{a}{m}$& $\biggl(\frac{a}{m^2},\frac{2a}{m}\biggr)$  \\
$y^2=-4ax$ & $y=mx-\frac{a}{m}$ & $\biggl(-\frac{a}{m^2},\frac{2a}{m}\biggr)$  \\
$x^2=4ay$ & $y=mx-am^2$& $\bigl(2am,am^2\bigr)$  \\
$x^2=-4ay$ & $y=mx+am^2$& $\bigl(-2am,-am^2\bigr)$  \\
\end{NiceTabular}
\end{center}
\end{document} • It is saying "cell-space-top-limit " is unknown for the package nicematrix and few more errors when I build and run. Aug 24, 2020 at 19:29
• I think you have not the latest version of nicematrix. You should update your TeX installation (MiKTeX, TeXLive or MacTeX). Aug 24, 2020 at 19:43
• I am new to latex and using overleaf. Aug 24, 2020 at 19:57
• Send me a mail (fpantigny@wanadoo.fr) and I will send you the latest version of nicematrix.sty to upload in Overleaf in the directory of your Overleaf project. Aug 24, 2020 at 20:04
• @Davide Carlisle: Right. I have modified (I had copied the code of the OP without modifying that point). Aug 24, 2020 at 20:08

With use of the nccmath, cellspace, and hhline packages and array for table:


\documentclass{article}
\usepackage{nccmath}
\usepackage[table]{xcolor}
\usepackage{cellspace, hhline}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}

\begin{document}
$\begin{array}{ |c | c | >{}Sc<{}|} \hhline{---} \rowcolor{blue!50} \text{\textcolor{white}{Parabola}} & \text{\textcolor{white}{Equation of Tangent}} & \text{\textcolor{white}{Point of Contact}} \\ \hhline{---} y^2=4ax & y=mx+\frac{a}{m} & \Bigl(\mfrac{a}{m^2},\mfrac{2a}{m}\Bigr) \\ \hhline{---} y^2=-4ax & y=mx-\dfrac{a}{m} & \Bigl(-\mfrac{a}{m^2},\mfrac{2a}{m}\Bigr) \\ \hhline{---} x^2=4ay & y=mx-am^2 & \bigl(2am,am^2\bigr) \\ \hhline{---} {x^2=-4ay} & y=mx+am^2 & \bigl(-2am,-am^2\bigr) \\ \hhline{---} \end{array}$
\end{document} Addendum: Version where equation in cells are aligned at equal sign and points at commas:

\documentclass{article}
\usepackage{nccmath}
\usepackage[table]{xcolor}
\usepackage{cellspace, hhline}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcw{O{>{\color{white}}Sc|}m}
{\multicolumn{2}{#1}{#2}}
\usepackage[skip=1ex]{caption}

\begin{document}
$\setlength\arrayrulewidth{0.5pt} \setlength\arraycolsep{12pt} \begin{array}{ |r@{\,}l | >{\qquad}r@{\,}l | r@{,\,}>{}Sl<{}|} \hhline{*{6}{-}} \rowcolor{blue!50} \mcw[|>{\color{white}}Sc|]{Parabola} & \mcw{Equation of Tangent} & \mcw{Point of Contact} \\ \hhline{*{6}{-}} y^2 & = 4ax & y & =mx+\frac{a}{m} & \Bigl(\mfrac{a}{m^2} & \mfrac{2a}{m}\Bigr) \\ \hhline{*{6}{-}} y^2 & = -4ax & y & = mx-\dfrac{a}{m} & \Bigl(-\mfrac{a}{m^2} & \mfrac{2a}{m}\Bigr) \\ \hhline{*{6}{-}} x^2 & = 4ay & y & = mx-am^2 & \bigl(2am & am^2\bigr) \\ \hhline{*{6}{-}} x^2 & = -4ay & y & = mx+am^2 & \bigl(-2am & -am^2\bigr) \\ \hhline{*{6}{-}} \end{array}$
\end{document} • Is there any easy way to remove second and third vertical line in first row only? Aug 26, 2020 at 9:21
• @Mathematics, it is possible, but not very easy (you need to use for each cell multicolumn with the same cell align as has column and with content in math mode). BTW, to my taste, this nod lead to nice table. I would rather remove all vertical lines and employ rules from booktabs package. However, you accept other answer, which has own specific to draw vertical lines ... you should ask @F. Pantigny. Aug 26, 2020 at 10:32