# vertical alignment of multirow tables in lyx

After having searched a lot, I still didn't find an option to align multirow cells vertically correctly in Lyx' native tables. There seem to be some solutions but I haven't found any for use with Lyx native tables without individually adjusting the vertical displacement.

I created an example file to show what I mean and the corresponding rendering. The code in Lyx is as followed:

\begin{table}
\begin{centering}
\begin{tabular*}{1\textwidth}{@{\extracolsep{\fill}}>{\raggedright}m{0.2\textwidth}>{\raggedright}m{0.4\textwidth}>{\raggedright}m{0.3\textwidth}}
\toprule
\midrule
Extrusion & Fused Deposition Molding (FDM) & Thermoplaste (z.B. PLA, ABS), HDPE, eutektische Metalle, Gummi, Ton,
\midrule
Draht & Electron Beam Freeform Fabrication (EBF) & fast jede Metalllegierung\tabularnewline\addlinespace
\midrule
\multirow{5}{0.2\textwidth}{Granulate } & Direct metal laser sintering (DMLS) & fast jede Metalllegierung\tabularnewline\addlinespace
\cmidrule{2-3}
& Electron-beam melting (EBM) & Titanlegierungen\tabularnewline\addlinespace
\cmidrule{2-3}
& Selective laser melting (SLM) & Titanlegierungen, Kobalt-Chrom-Legierungen, stainless-steel, Aluminium\tabularnewline\addlinespace
\cmidrule{2-3}
& Selective heat sintering (SHS) & thermoplastisches Pulver\tabularnewline\addlinespace
\cmidrule{2-3}
& Selective laser sintering (SLS) & Thermoplasten, Metallpulver, keramische Pulver\tabularnewline\addlinespace
\midrule
\multirow{2}{0.2\textwidth}{Pulverbett mit Inkjetkopf} & Plaster based 3D printing (PP) & Gips mit Wasser als Binder\tabularnewline\addlinespace
\cmidrule{2-3}
& kein einheitlicher Name findbar & Sand/Kunststoff mit Binder\tabularnewline\addlinespace
\midrule
Laminiert & Laminated object manufacturing (LOM) & Papier, Metallfolie, Plastikfilm\tabularnewline\addlinespace
\midrule
\multirow{2}{0.2\textwidth}[-2mm]{Photoaktivierte Polymerisation} & Stereolithographie (SLA) & \multirow{2}{0.3\textwidth}{Photopoylmere}\tabularnewline\addlinespace
\cmidrule{2-2}
& Digital Light Processing (DLP) & \tabularnewline\addlinespace
\bottomrule
\end{tabular*}
\par\end{centering}

\protect\caption{Übersicht über verschiedene additive Fertigungsverfahren in Anlehnung
an \cite{wikipedia20143Dprinting}. \label{tab:=0000DCbersicht =0000FCber verschiedene additive Fertigungsverfahren}}
\end{table}


Focus on the word "granulate"

In this question here, they showed how to use the second optional argument but isn't there an automatic way?

• Instead of placing Granulate in the first row of the area that it should span via a \multirow, place it in the third row, then it will be centred automatically without using a \multirow. – Werner Jul 5 '14 at 15:31
• thank you for the tip, I hadn't considered that but that doesn't help me in the case of "photoaktivierte Polymerisation" as the cell is spanning two rows. (I mentioned the aligniment problem (at least I percieve it as such. If I'm wrong, please show me) in the comment thread under the answer of @bernard ). Also, this solution works great in the case of odd multirow numbers, but if they are even, this isn't a viable solution – Hug Jul 6 '14 at 18:51

You must count not the number of rows, but the number of lines in case of multiline cells, plus an adjustement corresponding to the number of \addlinespace commands and to the thickness of \midrules. However this is only theoretical. For instance, I chose not to put "granulate" in the middle of its multirow cell, but aligned with "Selective laser melting" in the next column, as to the eye it appears as the vertical centre of the table. But you can try the version "vertically centred" if you wish: just comment the corresponding line and uncomment the line above.

Also, note the centering environment does not exist. It's the \centering command that you have to use.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{array, multirow, booktabs}
\usepackage{amsmath}

\pagestyle{empty}

\begin{document}

\begin{table}
\centering
\begin{tabular*}{1\textwidth}{@{\extracolsep{\fill}}>{\raggedright}m{0.2\textwidth}>{\raggedright}m{0.4\textwidth}>{\raggedright}m{0.3\textwidth}}
\toprule
\midrule
Extrusion & Fused Deposition Molding (FDM) & Thermoplaste (z.B. PLA, ABS), HDPE, eutektische Metalle, Gummi, Ton,
\midrule
Draht & Electron Beam Freeform Fabrication (EBF) & fast jede Metalllegierung\tabularnewline\addlinespace
\midrule
%\multirow{13}{0.2\textwidth}[\dimexpr-5\defaultaddspace-4\lightrulewidth]{Granulate } & Direct metal laser sintering (DMLS) & fast jede Metalllegierung\tabularnewline\addlinespace
\multirow{13}{0.2\textwidth}[\dimexpr-2\defaultaddspace + 3\lightrulewidth\relax]{Granulate } & Direct metal laser sintering (DMLS) & fast jede Metalllegierung\tabularnewline\addlinespace
\cmidrule{2-3}
& Electron-beam melting (EBM) & Titanlegierungen\tabularnewline\addlinespace
\cmidrule{2-3}
& Selective laser melting (SLM) & Titanlegierungen, Kobalt-Chrom-Legierungen, stainless-steel, Aluminium\tabularnewline\addlinespace
\cmidrule{2-3}
& Selective heat sintering (SHS) & thermoplastisches Pulver\tabularnewline\addlinespace
\cmidrule{2-3}
& Selective laser sintering (SLS) & Thermoplasten, Metallpulver, keramische Pulver\tabularnewline\addlinespace
\midrule
\multirow{4}{0.2\textwidth}{Pulverbett mit Inkjetkopf} & Plaster based 3D printing (PP) & Gips mit Wasser als Binder\tabularnewline\addlinespace%
\cmidrule{2-3}
& kein einheitlicher Name findbar & Sand/Kunststoff mit Binder\tabularnewline\addlinespace
\midrule
Laminiert & Laminated object manufacturing (LOM) & Papier, Metallfolie, Plastikfilm\tabularnewline\addlinespace
\midrule
\cmidrule{2-2}
& Digital Light Processing (DLP) & \tabularnewline\addlinespace
\bottomrule
\end{tabular*}
\protect\caption{Übersicht über verschiedene additive Fertigungsverfahren in Anlehnung%
an \cite{wikipedia20143Dprinting}. \label{tab:=0000DCbersicht =0000FCber verschiedene additive Fertigungsverfahren}}
\end{table}

\end{document}


• thank you for the quick answer. This looks great, but leaves me with other questions: 1. How do I implement this in Lyx? (As it is using Lyx native tables, hjow do I modify the code accordingly?) 2. can I somewhow align "Photoaktivierte Polymerisation" correctly or is this related to booktabs? It doesn't look vertically correctly aligned either. Or am I wrong here? – Hug Jul 6 '14 at 18:47
• 1. I don't know Lyx, so I only can conjecture that you'll have to manually adjust as I've done starting with your (=Lyx's) code — unless there's a way to tell Lyx to count the number of lines in multiline cells… 2. To my eyes, "Photoaktivierte Polymerisation" is correctly aligned as extending midrule in next column would make it pass through the middle of these two lines. You can try to make a [-1.5\defaultaddspace] adjustment in the multirows of the 1st and 3rd columns (instead of -2), it is also acceptable. It's only a matter of personal taste. – Bernard Jul 6 '14 at 19:23
• Hi, I marked the answer as solved because I'm now using the code in a code block. But I stumbled upon a really strange behaviour: It only compiles if I have the old table (I commented it out with a beginning "\iffalse" and an ending "\fi") anywhere in the document. Otherwise, it throws a "undefined control sequence" error. Thank you very very much for your help. – Hug Jul 7 '14 at 10:58
• @Hug: I am confident there is no native way to do this in LyX, aside from using ERTs wherever something using pure LaTeX is needed. LyX has its limitations, and this is most certainly one of them... – Werner Jul 7 '14 at 15:36
• @Werner, thanks for the answer. Do you have any idea why Lyx doesn't compile in any way the moment I delete the old (not even compiled) table build natively with Lyx? I have an ERT block in front of the table float (of the native table) (for docu and for trying out) with "iffalse" and one with "fi" after it. When I delete all of that and just use the ERT in the table float from above, it doesn't compile. But it does when the old native lyx is anywhere in the document. – Hug Jul 8 '14 at 17:07