2

I am trying to reproduce the result of this answer:

https://tex.stackexchange.com/a/167022/25764

However, I do not get the same results when I type the same.

This is the code:

\documentclass{article}

\usepackage{array}

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

\begin{document}

\begin{table}[htbp] \centering \begin{tabular}{|C{3cm}|L{4cm}|C{3.5cm}|N} \hline \textbf{\textit{fine/coarse}} & \textbf{Property} & \textbf{\textit{lamellar/equiaxed}} &\[20pt] \hline x/x & Elastic Modulus & x/+ &\[20pt] \hline +/- & Strength & -/+ &\[20pt] \hline +/- & Ductility & -/+ &\[20pt] \hline +/- & Fatigue crack initiation & -/+ &\[20pt] \hline -/+ & Fatigur crack propagation & +/- &\[20pt] \hline +/- & Oxidation Behaviour & +/- &\[20pt] \hline \end{tabular} \label{table:eomsomeprops} \end{table}

\end{document}

This is the expectation: Expected Result

This is what I get:

whatIget

Note that, the cell heights are proper, but they are not centered vertically. I am using miktex on windows.

What can I do to fix the problem?

3 Answers3

2

By using of the tabularray package the MWE is very simple and short:

\documentclass{article}
\usepackage{tabularray}

\begin{document} \begin{table}[htbp] \centering \begin{tblr}{hlines, vlines, colspec = {c l c}, %{Q[c, wd=3cm] Q[l, wd=4cm] Q[c, wd=3.5cm]} row{1} = {font=\bfseries, c}, rowsep=3ex, } \textit{fine/coarse} & Property & \textit{lamellar/equiaxed} \ x/x & Elastic Modulus & x/+ \ +/- & Strength & -/+ \ +/- & Ductility & -/+ \ +/- & Fatigue crack initiation & -/+ \ -/+ & Fatigur crack propagation & +/- \ +/- & Oxidation Behaviour & +/- \ \end{tblr} \label{table:eomsomeprops} \end{table} \end{document}

enter image description here

Zarko
  • 296,517
1

You can easily obtain what you want with the cellspace package, which lets you define minimal vertical spacings at the top and bottom of cells in columns with specifier prefixed with the letter S (or C if you load siunitx). Here is a possible code:

    \documentclass{article}
\usepackage{array}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{3.5ex}
\setlength{\cellspacebottomlimit}{2ex}
\newcolumntype{C}[1]{>{\centering\arraybackslash}S{m{#1}}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}S{m{#1}}}
\newcolumntype{N}{@{}m{0pt}@{}}

\begin{document}

\begin{table}[htbp]
\centering
\begin{tabular}{|C{3cm}|L{4cm}|C{3.5cm}|N}
\hline
\textbf{\textit{fine/coarse}} & \textbf{Property} & \textbf{\textit{lamellar/equiaxed}} &\\[20pt]
\hline
x/x & Elastic Modulus & x/+ &\\[20pt]
\hline
+/- & Strength & -/+ &\\[20pt]
\hline
+/- & Ductility & -/+ &\\[20pt]
\hline
+/- & Fatigue crack initiation & -/+ &\\[20pt]
\hline
-/+ & Fatigur crack propagation & +/- &\\[20pt]
\hline
+/- & Oxidation Behaviour & +/- &\\[20pt]
\hline
\end{tabular}
\label{table:eomsomeprops}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
0

You can achieve the desired effect by vertically stretching a table. Simply add \renewcommand\arraystretch{<factor>}, something like 3.0. Because stretching this way is not quite symmetric, a remedy is to reduce upper space via \setlength\extrarowheight{<v-length>}, e.g. -3pt.

enter image description here

Another solution, similar to \\[20pt] is to define a strut

\newcommand\mystrut{\rule{0pt}{30pt}}

which you add at the end of each row, right before \\, for instance

x/x & Elastic Modulus & x/+ & \mystrut\\

but IMO it causes unnecessary clutter.


The solution based on the arraystretch

\documentclass{article}
\usepackage{array}

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

\begin{document}

\begin{table}[htbp] \renewcommand{\arraystretch}{3.6} \setlength{\extrarowheight}{-3pt} \centering \begin{tabular}{|C{3cm}|L{4cm}|C{3.5cm}|N} \hline \textbf{\textit{fine/coarse}} & \textbf{Property} & \textbf{\textit{lamellar/equiaxed}} & \ \hline x/x & Elastic Modulus & x/+ &\ \hline +/- & Strength & -/+ &\ \hline +/- & Ductility & -/+ &\ \hline +/- & Fatigue crack initiation & -/+ &\ \hline -/+ & Fatigur crack propagation & +/- &\ \hline +/- & Oxidation Behaviour & +/- &\ \hline \end{tabular} \label{table:eomsomeprops} \end{table}

\end{document}

Celdor
  • 9,058