Vertical alignment on merged cells with multirow

Look, ma! No multirow! ;-)

\documentclass{article}
\usepackage{array,hhline}

\newcommand{\corner}[1]{%
  \begin{array}{@{}|c}
  #1\vphantom{\Big|}\\
  \hhline{|-}
  \multicolumn{1}{c}{\vphantom{\Big|}}\end{array}%
}
\newcommand{\entry}[1]{\quad#1\quad}

\begin{document}

$\begin{array}{@{}r@{\hspace{\arraycolsep}\vline}*{3}{c@{\vline}}}
 \multicolumn{1}{@{}c@{}}{}& \multicolumn{1}{c}{H1} & \multicolumn{1}{c}{H2} & \multicolumn{1}{c}{H3} \\
 \hhline{~|---}
 L1 & \entry{a_{11}}\corner{c_{11}}  & \entry{a_{12}}\corner{c_{12}} & \entry{a_{13}}\corner{c_{13}} \\
 \hhline{~|---}
 L2 & \entry{a_{21}}\corner{c_{21}}  & \entry{a_{22}}\corner{c_{22}} & \entry{a_{23}}\corner{c_{23}} \\
 \hhline{~|---}
 \end{array}$

\end{document}

enter image description here


A version of your tabular typeset using cals. This version two mimics the column width in the question (10mm/6mm+2tabcolsep+arrayrulewidth):


\documentclass{article}
\usepackage{cals}

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

\newcommand{\corner}{\dimexpr(6mm+12.4pt)\relax}          % Same column width as in the question
\newcommand{\noncorner}{\dimexpr(10mm+12.4pt)\relax} % Comepnsated for  and tabcolsep

\begin{document}

\begin{calstable}

% Defining seven columns relativ to each other and relativ to the margins.
\colwidths{{10mm}
            {\noncorner}
            {\corner}
            {\noncorner}
            {\corner}
            {\noncorner}
            {\corner}
    }

% 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}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0.4pt}             % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.4pt}


\def\tb{\ifx\cals@borderT\relax      % Top border switch (off-on)
    \def\cals@borderT{0pt}
\else \let\cals@borderT\relax\fi}

\def\bb{\ifx\cals@borderB\relax      % Botton border switch (off-on)
    \def\cals@borderB{0pt}
\else \let\cals@borderB\relax\fi}

\def\rb{\ifx\cals@borderR\relax      % Right border switch (off-on)
    \def\cals@borderR{0pt}
\else \let\cals@borderR\relax\fi}

\def\lb{\ifx\cals@borderL\relax      % Left border switch (off-on)
    \def\cals@borderL{0pt}
\else \let\cals@borderL\relax\fi}


% R1
\brow
    \rb\lb\tb\cell{}
    \nc{ltb}
    \nc{rtb}\alignC\sc{$H1$}
    \nc{ltb}
    \nc{rtb}\sc{$H3$}
    \nc{ltb}
    \nc{rtb}\sc{$H3$}\tb\lb\rb
\erow
% R2 Body
\brow
    \lb\tb\nc{lrt}\tb\lb
    \nc{lrt}
    \cell{$c11$}
    \nc{lrt}
    \cell{$c12$}
    \nc{lrt}
    \cell{$c13$}
\erow
% R3 Body
\brow
    \bb\lb\nc{lrb}\alignR\sc{\vfil $L1$}\lb\bb
    \alignC\nc{lrb}\sc{\vfil $a11$}
    \lb\cell{}\lb
    \nc{lrb}\sc{\vfil $a12$}
    \lb\cell{}\lb
    \nc{lrb}\sc{\vfil $a13$}
    \lb\cell{\rule{\baselineskip}{0pt}}\lb
\erow
% R4 Body
\brow
    \lb\nc{lrt}\lb
    \nc{lrt}
    \cell{$c21$}
    \nc{lrt}
    \cell{$c22$}
    \nc{lrt}
    \cell{$c23$}
\erow
% R5 Body
\brow
    \bb\lb\nc{lrb}\alignR\sc{\vfil $L2$}\lb\bb
    \alignC\nc{lrb}\sc{\vfil $a21$}
    \lb\cell{}\lb
    \nc{lrb}\sc{\vfil $a22$}
    \lb\cell{}\lb
    \nc{lrb}\sc{\vfil $a23$}
    \lb\cell{\rule{\baselineskip}{0pt}}\lb
\erow
\makeatletter
\end{calstable}\par % \par needed to align the tabular

\end{document}

enter image description here


  • With your MWE and using recent version of array package I cant reproduce in question showed image of table. The baselines of "L1" , "a1" and \clines below "c" cells are vertically aligned. Do you have recent version of LaTeX installation? Read comments below question
  • Your code can be much shorter (the most of \multicolumns{1}{...}{...} are superfluous, adding few of \multicolumns{2}{c}{}` simplify a code):
\documentclass{article}
\usepackage{multirow}
\usepackage{array}
\newcommand{\nocorner}{1cm}
\newcommand{\corner}{6mm}
\newcommand\mcc{\multicolumn{2}{c|}{}}  % new

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

\begin{table}
    \setlength\extrarowheight{3pt}
    \begin{tabular}{c | *{3}{C{\nocorner}|C{\corner}|} }
    \multicolumn{1}{c}{}
         & \multicolumn{2}{c}{$H1$} & \multicolumn{2}{c}{$H2$} & \multicolumn{2}{c}{$H3$}   \\ \cline{2-7}
    \multirow{2}{*}{$L1$}
        & \multirow{2}{*}{$a_{11}$}
            & $c_{11}$
                & \multirow{2}{*}{$a_{12}$} 
                    & $c_{12}$
                        & \multirow{2}{*}{$a_{13}$}
                            & $c_{13}$  \\
        \cline{3-3}\cline{5-5}\cline{7-7}
        & \mcc & \mcc & \mcc            \\
        \cline{2-7}
%
    \multirow{2}{*}{$L2$}
        & \multirow{2}{*}{$a_{21}$}
            & $c_{21}$
                & \multirow{2}{*}{$a_{22}$}
                    & $c_{22}$
                        & \multirow{2}{*}{$a_{23}$}
                            & $c_{23}$  \\
        \cline{3-3}\cline{5-5}\cline{7-7}
        & \mcc & \mcc & \mcc            \\
        \cline{2-7}
    \end{tabular}
    \setlength\extrarowheight{0pt}
\end{table}

\end{document}

enter image description here

Tags:

Multirow