I have a problem with the alignment of the heading in my table. Here I want to force a line break with the function \shortstack for the table headers. This works also so far.
However, I would like to align the heading to the top of the table. I have not found a working alternative for the \shortstack-function yet.
Solutions are offered here, but for some reason they do not work in my case: How to add a forced line break inside a table cell
Can someone help me to align the headers to the top? (And possibly left-aligned in addition?)
Here is my code:
\documentclass[]{article}
\usepackage[margin=1in]{geometry}
\usepackage{floatrow} \floatsetup[figure]{capposition=top} \floatsetup[table]{capposition=top} \usepackage{setspace}
\usepackage{siunitx} \newcolumntype{d}{S[table-format=2.1]}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage[usestackEOL]{stackengine}
\begin{document}
\begin{tabu} to \linewidth {>{\raggedright}l|d|dddd}
\toprule
\shortstack{CAAR\Window} & \shortstack{All\transaction\forms} & \shortstack{Acquisition Of\ Partial Interest} & \shortstack{Acquisition Of\ Majority Assets} & \shortstack{Acquisition Of \ Remaining Interest} & \shortstack{Merger}\
\midrule
{(-15,-2)} & 1.7*** & 1.3** & 1.8** & 2.2*** & 2.0*\
{(-10,-1)} & 1.9* & 0.9** & 2.2*** & 2.4*** & 2.5*\
{(-5,-1)} & 1.3* & 0.9*** & 1.2*** & 1.4*** & 1.7*\
{(-5,+5)} & 13.3* & 5.7*** & 12.2*** & 14.7*** & 20.9*\
{(-2,+2)} & 12.6* & 5.5*** & 11.1*** & 13.8*** & 19.9*\
{(-1,+1)} & 11.8* & 5.0*** & 9.8*** & 11.9*** & 19.4*\
{(0,0)} & 8.7* & 3.0*** & 6.3*** & 7.0*** & 16.0*\
{(0,+10)} & 12.1* & 4.9*** & 10.7*** & 13.5*** & 19.4*\
{(1,+10)} & 3.4* & 1.8*** & 4.4*** & 6.5*** & 3.5*\
{(2,+15)} & 1.2* & 0.4 & 1.6** & 2.1*** & 1.4***\
\bottomrule
\end{tabu}
\end{document}
I already used the \thead and the \makecell-function , but the table heading is shifted strangely:




\theadcommand, frommakecell? The default alignment is centred both vertically and horizeontally, but you can change it with an optional argument. In your case, if I understand well what you want,\thead[tc]{…}would do it – if it is compatible withtabu. – Bernard Apr 15 '21 at 08:26\thead[tc]{…}- command, but the table heading is shifted strangely. See my edit. – TobKel Apr 15 '21 at 08:29\shortstacks with only two rows? – Bernard Apr 15 '21 at 08:32\shortstack{CAAR\\Window \\ { }gives me a centered aligned heading not a top aligned. – TobKel Apr 15 '21 at 08:37\phantom{A}in the third row? – Bernard Apr 15 '21 at 08:40