# Fit vertical text into table cell

I am making a relatively simple table in LaTeX however, I came across a problem. I am trying to make the following table:

However, I get the following:

My MWE is the following:

\documentclass{article}
\usepackage{graphicx,multirow}
\setbox0\hbox{\tabular{@{}l}Hydrocarbons\endtabular}
\begin{document}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{System} & K-Model & H-Model \\
\hline
\multirow{4}{*}{\rotatebox{90}{\rlap{\usebox0}}} \\
& Ordinary & SRK &SRK  \\ \cline{2-4}
& Cryogenics & PR & PR \\ \cline{2-4}
& Crude & CS, GS & LK \\ \cline{2-4}
& Vacuum Crude & ESSO & LK\\ \hline
\hline
\multicolumn{2}{|c|}{Power combustion} & SRK &SRK \\ \hline
\multicolumn{2}{|c|}{Acid, Bases, Electrolytes} & Electrolytes Models &SRK,
HTSL\\ \hline
\multicolumn{2}{|c|}{Chemicals} & Activity Coeff. & Latent Heat\\ \hline
\end{tabular}
\end{document}​

• I increased the height of the cells a little, is this good? Mar 19, 2018 at 19:55
• Yes, it is!! how did you do it? Mar 19, 2018 at 19:57
• I posted an answer with the code and explanation :) Mar 19, 2018 at 20:15

I changed a few things:

• I changed the \box0 to a \newbox\dontdoitbox. If you use box registers directly you may overwrite things you shouldn't overwrite. I put an automatic register instead (But still there's no point in using a box here...).

• I removed the \rlap from the \usebox. The \rlap makes the box start at the center of the cell, instead of the bottom.

• I included the array package and put \setlength{\extrarowheight}{6pt} to increase the height of the cells of the table to make everything fit.

Here's the result:

The code:

\documentclass{article}
\usepackage{graphicx,multirow}
\usepackage{array}
\setbox0\hbox{\tabular{@{}l}Hydrocarbons\endtabular}
\begin{document}
\pagenumbering{gobble}
\setlength{\extrarowheight}{6pt}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{System} & K-Model & H-Model \\
\hline
\multirow{4}{*}{\rotatebox{90}{\usebox0}}
& Ordinary & SRK &SRK  \\ \cline{2-4}
& Cryogenics & PR & PR \\ \cline{2-4}
& Crude & CS, GS & LK \\ \cline{2-4}
& Vacuum Crude & ESSO & LK\\ \hline
\hline
\multicolumn{2}{|c|}{Power combustion} & SRK &SRK \\ \hline
\multicolumn{2}{|c|}{Acid, Bases, Electrolytes} & Electrolytes Models &SRK,
HTSL\\ \hline
\multicolumn{2}{|c|}{Chemicals} & Activity Coeff. & Latent Heat\\ \hline
\end{tabular}
\end{document}


an alternative with use of packages makecell and rotating:

\documentclass{article}
\usepackage{makecell,multirow}
\usepackage{rotating}

\begin{document}
\begin{center}
\setcellgapes{5pt}
\makegapedcells
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{System}
& K-Model   & H-Model       \\\hline
& Ordinary      & SRK       & SRK           \\ \cline{2-4}
& Cryogenics    & PR        & PR            \\ \cline{2-4}
& Crude         & CS, GS    & LK            \\ \cline{2-4}
& Vacuum Crude  & ESSO      & LK            \\ \hline
\hline
\multicolumn{2}{|c|}{Power combustion}
& SRK       & SRK           \\ \hline
\multicolumn{2}{|c|}{Acid, Bases, Electrolytes}
& Electrolytes Models
& SRK, HTSL     \\ \hline
\multicolumn{2}{|c|}{Chemicals}
& Activity Coeff.
& Latent Heat   \\ \hline
\end{tabular}
\end{center}
\end{document}​


• You are very talented with LaTeX. I vote all +1. Mar 19, 2018 at 21:52