0

Having read the answer in How to make a row in a table shorter, I have another question: is there any way to make the row's height to be a fixed value (like 0.3cm)?

My table is the following:

\begin{tabular}{|c|c|c|}
  \hline
  a & b & c \\
  \hline
  {\tiny a} & {\tiny b} & {\tiny c} \\
  \hline
\end{tabular}

I want the second column to have a height as fixed length, rather than something like \setarstrut{\tiny} in Heiko Oberdiek's answer.

stone-zeng
  • 2,710

2 Answers2

2

a rude hack: add zero wide rule to each cell in the last column (as strut):

\documentclass[12pt]{article}
\usepackage{array}

\begin{document} \begin{tabular}{|c|c|c<{\rule[-2mm]{0pt}{7mm}}|} \hline a & b & c \ \hline \tiny a & \tiny b & \tiny c \ \hline a & b & c \ \hline \tiny a & \tiny b & \tiny c \ \hline \end{tabular} \end{document}

enter image description here

off-topic: \tiny is not environment, it is switch from one font size to tiny size. so the correct use is {\tiny a} or simple \tiny a if it use is limited by cell in table.

Zarko
  • 296,517
  • Thank you for your answer. But with your solution, I can onlt make the row to be higher, but can't be lower. Actually, what I hope to do is to make the "tiny" row to be lower, and have a fixed height (1cm may be too large, maybe 5mm?). – stone-zeng Jan 10 '18 at 03:59
  • @Stone-Zeng, sorry, this i didn't conclude from your question. from your comment i understand, that you like to have standard table features: cells' heights accommodate to font size. you might consider to determine additional vertical space which can be determined by macros from makecell or cellspace. please edit your question and clarify what you like to obtain. – Zarko Jan 10 '18 at 04:30
0

Following Heiko Oberdiek's answer, I finally get the way to change one row' height (and depth):

\documentclass{article}
\usepackage{array,xparse}

\makeatletter
\ExplSyntaxOn

% #1=height, #2=depth. They should be dimexpr.
\NewExpandableDocumentCommand \setarstrut { m m }
  { \mytab_set_array_strut:nn {#1} {#2} }
\NewExpandableDocumentCommand \restorearstrut { }
  { \mytab_restore_array_strut: }

\box_new:N \l__mytab_old_arstrut_box

\cs_new:Npn \mytab_set_array_strut:nn #1#2
  {
    \tex_noalign:D
      {
        \group_begin:
          % Store the old strutbox
          \box_gset_eq:NN \l__mytab_old_arstrut_box \@arstrutbox
          % Change the dimension of \@arstrutbox
          \hbox_set_to_wd:Nnn \l_tmpa_box { \c_zero_dim } { }
          \box_set_ht:Nn \l_tmpa_box {#1}
          \box_set_dp:Nn \l_tmpa_box {#2}
          \hbox_gset:Nn \@arstrutbox { \box_use:N \l_tmpa_box }
        \group_end:
      }
  }
\cs_new:Npn \mytab_restore_array_strut:
  {
    \tex_noalign:D
      { \box_gset_eq:NN \@arstrutbox \l__mytab_old_arstrut_box }
  }

\ExplSyntaxOff
\makeatother

\begin{document}

\begin{tabular}{|c|c|c|}
  \hline
  a & b & c \\
  \hline
  \setarstrut{4pt}{1.3pt}
  \tiny a & \tiny b & \tiny c \\
  \restorearstrut
  \hline
  a & b & c \\
  \hline
\end{tabular}

\end{document}

I use LaTeX3 to rewrite the code, but the main idea is the same: just to modify the box \@arstrutbox.

Result:

enter image description here

stone-zeng
  • 2,710