In a largetable, I want to obtain the following:
- All cells vertically aligned to the top
- Left column is horizontally centred, Right column is flushed left
To be clear in the picture below: - Alpha should be aligned with One
- Austria should be aligned with 1 I thought that using p instead of m should do the trick but obviously not, though there are many questions about alignment, I did not find the answer to this specific problem.
Obviously, long table, multicolumn and the small tabular are used here just to have a working example close to what is my actual document.
\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{L}[1]{>{\flushleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\begin{longtable}{| C{1cm} | C{1cm} | L{3cm} | L{3cm} |}
\hline
\multicolumn{2}{|C{2cm}|}{
\begin{tabular}[t]{c}
Alpha\\
Beta\\
Gamma\\
Delta
\end{tabular}
}&
\multicolumn{2}{L{6cm}|}{
\begin{tabular}[t]{c}
One\\
Two
\end{tabular}
}
\\\hline
\multicolumn{2}{|C{2cm}|}{
\begin{tabular}[t]{c}
Austria\\
Belgium
\end{tabular}
}&
\multicolumn{2}{L{6cm}|}{
\begin{tabular}[t]{c}
1\\
2\\
3
\end{tabular}
}
\\\hline
\end{longtable}
\end{document}
flushleft
is never inteneded to be used in command form it is the\begin{flushleft}
environment and likecenter
it adds vertical space (as you see) the analogue of\centering
is\raggedright
. also you presumably wantp
notm
columns if you want top alignment.