Graphics, Figures & TablesHow to vertically center math objects in a table cell?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

How to vertically center math objects in a table cell?

Post by yoyoimut »

Dear all,

I am creating a table of formulae. The left column is for numbering and the right one is for the formula.
table.jpg
table.jpg (102.36 KiB) Viewed 2013 times
My question is how to vertically center the formula without using a magic constant obtained from trial and error adjustment?

Here is my code snippet that has been simplified.

Code: Select all

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array,longtable}


\newcounter{counter}
\renewcommand{\thecounter}{\stepcounter{counter}\raisebox{-0.63\depth}{\color{red}\bf\Large\arabic{counter}.}}
\newcolumntype{L}{>{\thecounter}r}
\newcolumntype{R}[1]{>{\parbox[c][#1][c]{0mm}{}\color{red}\Large\centering\arraybackslash$\displaystyle}m{0.5\linewidth}<{$}}



\begin{document}
\begin{longtable}{|L|R{15mm}|}\hline
\multicolumn{1}{|>{\Large\color{red}\bf}c|}{No} & \textrm{Equation}\\\hline
&  	\nabla\cdot\mathbf{D}=\rho_f \\\hline
&  	\nabla\cdot\mathbf{B}=0 \\\hline
&  	\nabla\times\mathbf{E}=-\frac{\partial \mathbf{B}}{\partial t} \\\hline
&  	\nabla\times\mathbf{H}=\mathbf{J}_f+\frac{\partial \mathbf{D}}{\partial t} \\\hline
&  	\int_a^b f(x)\, dx=F(b)-F(a) \\\hline
&		\sin x\\\hline
&  	\nabla\cdot\mathbf{D}=\rho_f \\\hline
&  	\nabla\cdot\mathbf{B}=0 \\\hline
&  	\nabla\times\mathbf{E}=-\frac{\partial \mathbf{B}}{\partial t} \\\hline
&  	\nabla\times\mathbf{H}=\mathbf{J}_f+\frac{\partial \mathbf{D}}{\partial t} \\\hline
&  	\int_a^b f(x)\, dx=F(b)-F(a) \\\hline
&		\sin x\\\hline
&  	\nabla\cdot\mathbf{D}=\rho_f \\\hline
&  	\nabla\cdot\mathbf{B}=0 \\\hline
&  	\nabla\times\mathbf{E}=-\frac{\partial \mathbf{B}}{\partial t} \\\hline
&  	\nabla\times\mathbf{H}=\mathbf{J}_f+\frac{\partial \mathbf{D}}{\partial t} \\\hline
&  	\int_a^b f(x)\, dx=F(b)-F(a) \\\hline
&		\sin x\\\hline
&  	\nabla\cdot\mathbf{D}=\rho_f \\\hline
&  	\nabla\cdot\mathbf{B}=0 \\\hline
&  	\nabla\times\mathbf{E}=-\frac{\partial \mathbf{B}}{\partial t} \\\hline
&  	\nabla\times\mathbf{H}=\mathbf{J}_f+\frac{\partial \mathbf{D}}{\partial t} \\\hline
&  	\int_a^b f(x)\, dx=F(b)-F(a) \\\hline
&		\sin x\\\hline
&  	\nabla\cdot\mathbf{D}=\rho_f \\\hline
&  	\nabla\cdot\mathbf{B}=0 \\\hline
&  	\nabla\times\mathbf{E}=-\frac{\partial \mathbf{B}}{\partial t} \\\hline
&  	\nabla\times\mathbf{H}=\mathbf{J}_f+\frac{\partial \mathbf{D}}{\partial t} \\\hline
&  	\int_a^b f(x)\, dx=F(b)-F(a) \\\hline
&		\sin x\\\hline
&  	\nabla\cdot\mathbf{D}=\rho_f \\\hline
&  	\nabla\cdot\mathbf{B}=0 \\\hline
&  	\nabla\times\mathbf{E}=-\frac{\partial \mathbf{B}}{\partial t} \\\hline
&  	\nabla\times\mathbf{H}=\mathbf{J}_f+\frac{\partial \mathbf{D}}{\partial t} \\\hline
&  	\int_a^b f(x)\, dx=F(b)-F(a) \\\hline
&		\sin x\\\hline
\end{longtable}
\end{document}

Thank you in advance.


regards,

Yuko

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to vertically center math objects in a table cell?

Post by gmedina »

Hi,

you could try some of the features provided by the makecell package.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply