This question is about three things:
- Making forced line break in a cell
- Combining above with
\rowcolors
- Combining above with vertical lines
1.This is obviously a common problem, since I have read several threads about this. But, I have not yet found any real solution to this extremely irritating problem, just trick-fixes.
Basically, I have a table, and in the first column I have a name, a letter and a unit, where I would like the letter and the unit on a second row to save horizontal space. I have tried:
p{}
set column width: Doesn't work since the contents are not of the same length.\newline
: Which worked ONE time (?) when using tabulary, then it stopped working.\parbox
: But I don't want to sit and put boxwidth for each cell, that seems completely unnecessary.\makecell
and\thead
: These two works fine and allows\\
inside! They both gives the best line break and cell shapes automatically\pbox
: gives similar result as above but other alignments.
BUT, now to part 2:
\makecell
and \thead
(and \pbox
) completely messes up \rowcolors
. It obviously handles the two-line cell as two cells or whatever. SO, how do I solve this problem? Is there another way of inserting line break in a cell or can the \rowcolors
be manipulated? Can the \makecell
be manipulated? Haven't found any answer in the CTAN manual for \makecell
package
3.And further, this is also a known issue. When implementing \rowcolors
, the colored rows messes up the vertical lines... They are not completely covered, but half covered of halfed in width, which looks like shit. Same crap when using \rowcolor
. I've tried \setlength\arrayrulewidth{1pt}
but that only increases width of all lines, not compensating those parts that are messed up. Any wonderful suggestions?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage{tabulary}
\usepackage{float}
\definecolor{lg}{gray}{0.9}
\begin{document}
\begin{table}[H]
\centering
\rowcolors{1}{lg}{}
\begin{tabulary}{1\textwidth}{|l|C C C C C|}\hline
No. & 1 & 2 & 3 & 4 & 5\\
\makecell[l]{Name} & DIN CK45 & M244 & Alumec 89 & HPFS 7980 & Ti-6Al-4V (Grade 5)\\
\makecell[l]{Type} & HTS & Cast Alu. & Aluminium & Fused Silica & Titanium \\
\makecell[l]{Young's modulus \\ E [GPa]} & 210 & 90 & 71.5 & 72.7 & 113.8 \\
\makecell[l]{Poisson's ratio \\ $\nu$ [1]} & 0.3 & 0.3 & 0.3 & 0.16 & 0.34 \\
\makecell[l]{Yield strength \\ $\sigma_y$ [MPa]} & 500 & 185 & 550 & - & 880 \\
\makecell[l]{Ultimate strength \\ $\sigma_u$ [MPa]} & 585 & 190 & 590 & 52.4 & 950 \\
\makecell[l]{Reference temp. \\ $t_{ref}$ [\degree C]} & - & 25 & 25 & 25 & - \\
\makecell[l]{Density \\ $\rho$ [kg/m\textsuperscript{3}]} & 7840 & 2650 & 2830 & 2201 & 4430 \\
\makecell[l]{Manufacturer} & Metal Ravne & MAHLE & UDDEHOLM & CORNING & - \\ \hline
\end{tabulary}
\caption{Material data}
\label{tab:materials1}
\end{table}
\end{document}