6

How to align the text in middle by specifying the row height could someone help me.

The latex code is as follows..

    \begin{table}[htbp]
    \centering
    \begin{tabular}{|c|l|c|}
    \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}

Output is attached.enter image description here I want something similar to this: enter image description here

1 Answers1

3

Like this?

enter image description here

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} 

I've defined two new types of columns (requires the array package)

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}

which are fixed columns but center their contents vertically.

When you break a row, use something like \\[20pt] instead of simply \\ to have the correct spacing.

Also, a new column of type N so defined

\newcolumntype{N}{@{}m{0pt}@{}}

is needed as the last one to avoid the problem described here: Vertical alignment in table: m-column, row size - problem in last column.

karlkoeller
  • 124,410
  • @user48432 You're welcome. I've added some explanations. – karlkoeller Mar 22 '14 at 10:31
  • My love to LAteX is growing infinetely. Awesome explanation :) (y) – walterhunk Mar 22 '14 at 10:32
  • I have literally copy-pasted your code clean and it is everything, but not vertically centering... the row's content is aligning to top... Can any TEX environment / ide mess with this? – Vinz Aug 17 '22 at 12:41