Graphics, Figures & TablesTable Cell Height and \arraystretch

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ChelseaBoot
Posts: 7
Joined: Fri Jun 17, 2011 9:54 am

Table Cell Height and \arraystretch

Post by ChelseaBoot »

I have been trying to rescale the height of cells in a table:

Code: Select all

\begin{table}[htbp]
\begin{center}
\begin{tabular}{>{$\displaystyle}p{.2\textwidth}<{$}     >{$\displaystyle}p{.3\textwidth}<{$}}
%================================%
\toprule
\textbf{Derivative} & \textbf{Expression} \\
\toprule
\dfrac{\partial \mathbi{X}\transp\mathbf{A}\mathbi{X}}{\partial\mathbi{X}} &= \underbrace{\left(\mathbf{A}+\mathbf{A}\transp\right)\mathbi{X}}_{\textit{Column Vector}} &\\
\dfrac{\partial \mathbi{X}\transp\mathbf{A}\mathbi{X}}{\partial\mathbi{X}\transp} &= \underbrace{\mathbi{X}\transp\left(\mathbf{A}+\mathbf{A}\transp\right)}_{\textit{Row Vector}}&\\
%================================%
\midrule
\dfrac{\partial \mathbi{A}\transp\mathbi{X}}{\partial \mathbi{X}} &= \mathbi{A} \\
\dfrac{\partial \mathbi{X}\transp\mathbi{A}}{\partial\mathbi{X}} &= \mathbi{A}\\
\dfrac{\partial \mathbi{A}\transp\mathbi{X}}{\partial \mathbi{X}\transp} &= \mathbi{A}\transp \\
\dfrac{\partial \mathbi{X}\transp\mathbi{A}}{\partial\mathbi{X}\transp} &= \mathbi{A}\transp \\
%================================%
%\midrule
%\dfrac{\partial}{\partial} &= \\
%\dfrac{\partial}{\partial} &= 
%================================%
\bottomrule
\end{tabular}
\end{center}
\end{table}
with an

Code: Select all

\renewcommand{\arraystretch}{1.1}
but only the top half of the table seems to get adjusted and the bottom half cells tend to run into each other.

Any clues how to solve this?

Thanks
Last edited by ChelseaBoot on Sun Jun 19, 2011 3:18 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table Cell Height and \arraystretch

Post by localghost »

Please provide a minimal example that is compilable as provided for everybody.


Thorsten
ChelseaBoot
Posts: 7
Joined: Fri Jun 17, 2011 9:54 am

Table Cell Height and \arraystretch

Post by ChelseaBoot »

Sorry!

Code: Select all

\documentclass[a4paper]{article}

\usepackage{amsmath,amssymb}
\usepackage{tabularx}
\usepackage{bm}
\usepackage{booktabs}

\renewcommand{\arraystretch}{1.1}
\def\mathbi#1{\textbf{\em #1}}
\newcommand{\transp}{^{\mathsf{T}}}

\begin{document}

\begin{table}[htbp]
\begin{center}
\begin{tabular}{>{$\displaystyle}p{.2\textwidth}<{$}     >{$\displaystyle}p{.3\textwidth}<{$}}
%================================%
\toprule
\textbf{Derivative} & \textbf{Expression} \\
\toprule
\dfrac{\partial \mathbi{X}\transp\mathbf{A}\mathbi{X}}{\partial\mathbi{X}} &= \underbrace{\left(\mathbf{A}+\mathbf{A}\transp\right)\mathbi{X}}_{\textit{Column Vector}} &\\
\dfrac{\partial \mathbi{X}\transp\mathbf{A}\mathbi{X}}{\partial\mathbi{X}\transp} &= \underbrace{\mathbi{X}\transp\left(\mathbf{A}+\mathbf{A}\transp\right)}_{\textit{Row Vector}}&\\
%================================%
\midrule
\dfrac{\partial \mathbi{A}\transp\mathbi{X}}{\partial \mathbi{X}} &= \mathbi{A} \\
\dfrac{\partial \mathbi{X}\transp\mathbi{A}}{\partial\mathbi{X}} &= \mathbi{A}\\
\dfrac{\partial \mathbi{A}\transp\mathbi{X}}{\partial \mathbi{X}\transp} &= \mathbi{A}\transp \\
\dfrac{\partial \mathbi{X}\transp\mathbi{A}}{\partial\mathbi{X}\transp} &= \mathbi{A}\transp \\
%================================%
%\midrule
%\dfrac{\partial}{\partial} &= \\
%\dfrac{\partial}{\partial} &= 
%================================%
\bottomrule
\end{tabular}
\end{center}
\end{table}

\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Table Cell Height and \arraystretch

Post by Stefan Kottwitz »

Good that you posted a minimal example! So I could test it too. You will see that also the rows below will be adjusted if you raise the value of \arraystretch, set it for example to 2.5. Of course this is too much.

Btw. there are errors in the code: at the end of rows remove the & before \\.

You can extend the space between rows manually, write at the end of a row for example

Code: Select all

\\[3ex]
Stefan
LaTeX.org admin
ChelseaBoot
Posts: 7
Joined: Fri Jun 17, 2011 9:54 am

Re: Table Cell Height and \arraystretch

Post by ChelseaBoot »

Ah, those "&"s are left over from a different table formatting. Thanks for pointing them out.

And the "[3ex]" works quite well. Thank you.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table Cell Height and \arraystretch

Post by localghost »

The booktabs package provides the \addlinespace command to insert additional space between lines. And by the way, to depict a transposed matrix you can simply use ^ \top.
ChelseaBoot
Posts: 7
Joined: Fri Jun 17, 2011 9:54 am

Re: Table Cell Height and \arraystretch

Post by ChelseaBoot »

Thanks for the reply localghost! "\addlinespace" is very useful.
Post Reply