0

In my table, I am using a multirow + multicolumn section to create a "merged" cell. However, I am running into an issue where the column borders bleed into that merged area. I provide an example with output below: is there an easy fix to remove the border overlapping A and B, while still keeping it for future rows? Thanks.

\documentclass[a4paper,oneside,11pt]{article}
\usepackage{multirow}
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}

\begin{document}
\begin{tabular}{c | c | c}
1 & 2 & 3 \\ \hline
\multicolumn{2}{c|}{\multirow{3}{*}{\minitab[c]{\textbf{A} \\ \textbf{B}}}} & a \\
& & b \\
& & c \\ \hline
d & e & f \\
\end{tabular}
\end{document}

LaTeX output

1 Answer 1

1

Since using a multicolumn environment overrides the tabular column definition, you simply need to specify a multicolumn for each of the "merged" rows you want. The modified code is below; note the two extra multicolumns replacing the two & & .

\documentclass[a4paper,oneside,11pt]{article}
\usepackage{multirow}
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}

\begin{document}
\begin{tabular}{c | c | c}
1 & 2 & 3 \\ \hline
\multicolumn{2}{c|}{\multirow{3}{*}{\minitab[c]{\textbf{A} \\ \textbf{B}}}} & a \\
\multicolumn{2}{c|}{} & b \\
\multicolumn{2}{c|}{} & c \\ \hline
d & e & f\\
\end{tabular}
\end{document}

The output:

LaTeX output

4
  • Thanks for the reply. But this does not work if there is another row below with distinct columns and where I would like to keep the vertical lines...
    – antoinef
    Jun 18, 2019 at 12:52
  • @antoinef Then please be more specific in your question: people can only answer what's being asked. If you intend to have more rows, will they follow the same format with the multicolumn? Or will they eventually be split into individual columns again?
    – Das_Geek
    Jun 18, 2019 at 12:56
  • sure. I have edited the original question.
    – antoinef
    Jun 18, 2019 at 13:01
  • @antoinef I edited my answer.
    – Das_Geek
    Jun 18, 2019 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .