[Tex/LaTex] Forcing minimum height for tabularx row

spacingtablestabularx

I have a tabularx table using multirow and with all columns vertically centered. Here's the table:

\usepackage{multirow,tabularx}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}
\def\tabularxcolumn#1{C{#1}}

\begin{tabularx}{\textwidth}{|C{3cm}|X|C{3cm}|N}
\hline
\multirow{2}{*}{\includegraphics[width=2.5cm]{logo}} &
\multirow{2}{*}{\Large{Title of this document}} &
    Doc.ref. &\\
\cline{3-3}
& & Revision &\\
\hline
\end{tabularx}%

I am looking for a way to force a minimum row height for a specific row in this table, but everything I tried didn't work for one reason or another.

  • \setlength{\extrarowheight}{1cm} breaks vertical alignment of the rightmost cells (they will not be vertically centered anymore)
  • Adding extra space when breaking the rows, e.g. &\\[1cm] breaks vertical alignment of the first two cells (the ones using \multirow)
  • Increasing the array stretch factor (e.g. \renewcommand{\arraystretch}{2.5}) doesn't seem to play nice with vertical alignments (it seems to push the contents of the cells below the vertical center)

Update: Manually adjusting positions will not work as this is a template — the actual document title is filled in later and may take one or two lines.

Any other ideas?

Best Answer

REVISED solution, which eliminates the multirow, instead using a nested tabulars. RE-REVISED to consolidate everything into \makemytable{height}, just to allow easier play-testing with various heights.

Here I just \addstackgap[<length>]{object} in order to add a vertical buffer above and below objects on that row. Buffer size added depends automatically upon the height of the inserted image.

\documentclass{article}
\usepackage{graphicx,stackengine}
\usepackage{multirow,tabularx}
\newsavebox\customimg
\def\bufferA{.5\dimexpr\ht\customimg+\dp\customimg+1\normalbaselineskip}
\def\bufferB{.25\dimexpr\ht\customimg+\dp\customimg+.5\normalbaselineskip}
\def\setimgheight#1{\savebox\customimg{%
  \raisebox{\dimexpr-\height+.5\normalbaselineskip} %
  {\includegraphics[width=2.5cm,height=#1]{example-image}}}
}
\def\makemytable#1{\setimgheight{#1}
  \begin{tabularx}{\textwidth}{|C{3cm}|X|@{\hspace{0pt}}C{3cm}@{\hspace{0pt}}|N}
  \hline
  \usebox{\customimg} &
  \addstackgap[\bufferA]{\Large{Title of this document}} &
  \begin{tabular}{@{\hspace{0pt}}c@{\hspace{0pt}}}
      \addstackgap[\bufferB]{\makebox[3.0cm]{Doc.ref.}} \\
  \hline
   \addstackgap[\bufferB]{Revision} \\
  \end{tabular}&\\
  \hline
  \end{tabularx}\par\medskip
}
\begin{document}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}
\def\tabularxcolumn#1{C{#1}}
\makemytable{1cm}
\makemytable{3cm}
\makemytable{5cm}
\end{document}

enter image description here

Related Question