1

I have created a table where some row cells are merged. Because of this, the merged cells are not "aligned" because two columns have different widths. It is more apparent when you look at an illustration of the table:

enter image description here

as you can see, the asterix's are not aligned with the middle of column 2 and 3. I was thinking of simply setting a fixed column width for these two columns, but I honestly have no idea how to. I have been using tablegenerator.com for convenience.. I have attached the code used to generate the table below:

\usepackage[table,xcdraw]{xcolor}

\begin{document}


\begin{table}[h]
\centering
\small
\begin{tabular}{|lcc|}
\hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Alford (1992)}} & {\color[HTML]{FFFFFF} \textbf{SIC}} & {\color[HTML]{FFFFFF} \textbf{SIC\Plus ROE}} \\ \hline
P/E & 24.5\% & 23.9\% \\
Pairwise difference significance & \multicolumn{2}{c|}{\textbf{*}} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{0.6\%}} \\ \hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Cheng and McNamara (2000)}} & {\color[HTML]{FFFFFF} \textbf{SIC}} & {\color[HTML]{FFFFFF} \textbf{SIC\Plus ROE}} \\ \hline
P/E & 27.6\% & 26.4\% \\
Pairwise difference significance & \multicolumn{2}{c|}{\textbf{***}} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{1.2\%}} \\ \hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Dittmann and Weiner (2005)}} & {\color[HTML]{FFFFFF} \textbf{SIC}} & {\color[HTML]{FFFFFF} \textbf{ROA\Plus Size}} \\ \hline
EV/EBIT & 33.4\% & 30.6\% \\
Pairwise difference significance & \multicolumn{2}{c|}{\textbf{***}} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{2.8\%}} \\ \hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Plenborg et al. (2017)}} & {\color[HTML]{FFFFFF} \textbf{GICS}} & {\color[HTML]{FFFFFF} \textbf{SARD}} \\ \hline
EV/EBIT & 25.5\% & 20.3\% \\
Pairwise difference significance & \multicolumn{2}{c|}{\textbf{***}} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{5.2\%}} \\ \hline
\end{tabular}
\end{table}

\end{document}
  • 1
    I don't understand what you mean by "the asterix's are not aligned with the middle of column 2 and 3" because they definitely are centred between those two columns. Do you want them to be aligned to the "line" where col 2 meets col 3 or what exactly are you trying to achieve? – Sam May 24 at 23:43
  • @Sam - Yes, that is actually what I mean. By aligning the asterixs to the line seperating column 2 and 3, the two column needs to be the same width – Philip May 25 at 7:10
  • Where is defined \Plus ?. Please make your code compilable. – Zarko May 29 at 15:38
2
+50

With p{...} columns in the second and third column and defined new commands:

enter image description here

\documentclass[a4paper,11pt]{report}
\usepackage[table,xcdraw]{xcolor}
\usepackage{array}
\newcommand\mclw[1]{\multicolumn{1}{l}{\color{white}\textbf{#1}}}
\newcommand\mccw[1]{\multicolumn{1}{c}{\color{white}\textbf{#1}}}
\newcommand\mcpc[1]{\multicolumn{2}{>{\centering\arraybackslash}p{8em}|}{\textbf{#1}}}

\begin{document}
    \begin{table}[ht]
    \centering
\small
\begin{tabular}{|l >{\centering\arraybackslash}p{3em}<{\,\%} 
                   >{\centering\arraybackslash}p{5em}<{\,\%}|}
    \hline
\rowcolor[HTML]{003085}
\mclw{Alford (1992)}                & \mccw{SIC}    & \mccw{SIC{+}ROE}  \\ 
    \hline
P/E                                 & 24.5          & 23.9\%            \\
Pairwise difference significance    & \mcpc{*}                          \\
Simple pairwise difference          & \mcpc{0.6\,\%}                    \\ 
    \hline
\rowcolor[HTML]{003085}
\mclw{Cheng and McNamara (2000)}    & \mccw{SIC}    & \mccw{SIC{+}ROE}  \\
P/E                                 & 27.6          & 26.4              \\
Pairwise difference significance    & \mcpc{***}                        \\
Simple pairwise difference          & \mcpc{1.2\,\%}                    \\ 
    \hline
\rowcolor[HTML]{003085}
\mclw{Dittmann and Weiner (2005)}   & \mccw{SIC}    & \mccw{SIC{+}Size} \\
EV/EBIT                             & 33.4          & 30.6              \\
Pairwise difference significance    & \mcpc{***}                        \\
Simple pairwise difference          & \mcpc{2.8\,\%}                    \\ 
    \hline
\rowcolor[HTML]{003085}
\mclw{Plenborg et al. (2017)}       & \mccw{SIC}    & \mccw{SARD}       \\
EV/EBIT                             & 25.5          & 20.3              \\
Pairwise difference significance    & \mcpc{***}                        \\
Simple pairwise difference          & \mcpc{5.2\,\%}                    \\ 
    \hline
\end{tabular}
    \end{table}
\end{document}
1

The package cals is also well suited to build such tabulars:

\documentclass[a4paper, 12pt]{report}
\usepackage{mathpazo, cals}
\usepackage[table, x11names]{xcolor}

\definecolor{darkblue}{HTML}{003085}

\let\nc=\nullcell                                                  % Shortcuts
\let\sc=\spancontent

\begin{document}

\begin{calstable}[c]
% Defining column relativ to each other and relativ to the margins
\colwidths{{\dimexpr(\columnwidth)/20*12\relax}
            {\dimexpr(\columnwidth)/20*4\relax}
            {\dimexpr(\columnwidth)/20*4\relax}
            }
% The tabular fills the text area if sum of all columns is 20

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.4pt}   % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.4pt}
\def\cals@bodyrs@width{0pt}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0pt}             % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0pt}
\def\cals@bgcolor{}

\def\blue{\ifx\cals@bgcolor\empty
    \def\cals@bgcolor{darkblue}
\else \def\cals@bgcolor{} \fi}

% R1H1
\brow
    \bfseries\blue\cell{\textcolor{white}{Alford (1992)}}
    \alignC\cell{\textcolor{white}{SIC}}
    \alignC\cell{\textcolor{white}{SIC+ROE}}\blue\mdseries
\erow
%R2H2
\brow
    \alignL\cell{P/E}
    \alignC\cell{24.5\,\%}
    \alignC\cell{23.9\,\%}
\erow
%R3B1
\brow
    \alignL\cell{Pairwise difference significance}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries *}
\erow
% R4B2
\brow
    \alignL\cell{Simpel pairwise difference}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries 0.6\,\%}
  \erow
%R5B3
% R1H1
\brow
    \bfseries\blue\alignL\cell{\vfil\textcolor{white}{Cheng and McNamara (2000)}}
    \alignC\cell{\textcolor{white}{SIC}}
    \alignC\cell{\textcolor{white}{SIC+ROE}}\blue\mdseries
\erow
%R2H2
\brow
    \alignL\cell{P/E}
    \alignC\cell{27.6\,\%}
    \alignC\cell{26.4\,\%}
\erow
%R3B1
\brow
    \alignL\cell{Pairwise difference significance}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries ***}
\erow
% R4B2
\brow
    \alignL\cell{Simpel pairwise difference}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries 1.2 \%}
  \erow
% R1H1
\brow
    \bfseries\blue\alignL\cell{\vfil\textcolor{white}{Dittmann and Weiner (2005)}}
    \alignC\cell{\textcolor{white}{SIC}}
    \alignC\cell{\textcolor{white}{SIC+Size}}\blue\mdseries
\erow
%R2H2
\brow
    \alignL\cell{EV/EBIT}
    \alignC\cell{33.4\,\%}
    \alignC\cell{30.6\,\%}
\erow
%R3B1
\brow
    \alignL\cell{Pairwise difference significance}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries ***}
\erow
% R4B2
\brow
    \alignL\cell{Simpel pairwise difference}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries 2.8 \%}
  \erow
% R1H1
\brow
    \bfseries \blue\alignL\cell{\textcolor{white}{Plenborg et al. (2017)}}
    \alignC\cell{\textcolor{white}{SIC}}
    \alignC\cell{\textcolor{white}{SIC+ROE}}\blue\mdseries
\erow
%R2H2
\brow
    \alignL\cell{P/E}
    \alignC\cell{25.5\,\%}
    \alignC\cell{20.3\,\%}
\erow
%R3B1
\brow
    \alignL\cell{Pairwise difference significance}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries ***}
\erow
% R4B2
\brow
    \alignL\cell{Simpel pairwise difference}
    \nc{ltb}
    \nc{rtb}\alignC\sc{\bfseries 5.2\,\%}
  \erow
\makeatletter
\end{calstable}\par
\end{document}

enter image description here

0

Try the following editions. I think the asterixs are now aligned to the imaginary line between second column and third column, but I am not sure this is the final layout you expect:

\documentclass{article}

\usepackage{bbding} % (<- put here the package you use for \Plus symbol)
\usepackage[table,xcdraw]{xcolor}

\begin{document}

\begin{table}[h]
\centering
\small
\begin{tabular}{|lcl|}
\hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Alford (1992)}} & {\color[HTML]{FFFFFF} \textbf{SIC}} & {\color[HTML]{FFFFFF} \textbf{SIC\Plus ROE}} \\ \hline
P/E & 24.5\% & 23.9\% \\
Pairwise difference significance & & \textbf{*} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{0.6\%}} \\ \hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Cheng and McNamara (2000)}} & {\color[HTML]{FFFFFF} \textbf{SIC}} & {\color[HTML]{FFFFFF} \textbf{SIC\Plus ROE}} \\ \hline
P/E & 27.6\% & 26.4\% \\
Pairwise difference significance & & \textbf{***} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{1.2\%}} \\ \hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Dittmann and Weiner (2005)}} & {\color[HTML]{FFFFFF} \textbf{SIC}} & {\color[HTML]{FFFFFF} \textbf{ROA\Plus Size}} \\ \hline
EV/EBIT & 33.4\% & 30.6\% \\
Pairwise difference significance & & \textbf{***} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{2.8\%}} \\ \hline
\rowcolor[HTML]{003085} 
{\color[HTML]{FFFFFF} \textbf{Plenborg et al. (2017)}} & {\color[HTML]{FFFFFF} \textbf{GICS}} & {\color[HTML]{FFFFFF} \textbf{SARD}} \\ \hline
EV/EBIT & 25.5\% & 20.3\% \\
Pairwise difference significance & & \textbf{ ***} \\
Simple pairwise difference & \multicolumn{2}{c|}{\textbf{5.2\%}} \\ \hline
\end{tabular}
\end{table}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.