Table Formatting – How to Make Nice Vertical Lines in a Table with LaTeX

tables

How to create nicer vertical lines in the table, please? They should go from the second line to the bottom line without overlapping and spaces.

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage{multirow}

\begin{document}
\begin{table}[h!]
\centering
\small
\begin{center}
\begin{tabular}{c|cc|cc|cc}
\hline\hline
A                   &\multicolumn{2}{c}{B}     &\multicolumn{2}{c}{C}  &\multicolumn{2}{c}{D}    \\
                                   
\hline
\multirow{2}{*}{A} &\multirow{2}{*}{B} &\multirow{2}{*} {C} &\multirow{2}{*}{D} &\multirow{2}{*}{E} &\multirow{2}{*}{F} &\multirow{2}{*}{G} \\
&&&&&&\\[-5pt]

\hline
\end{tabular}
\end{center}
\end{table}

\end{document}

enter image description here

Best Answer

It is not clear (to me) where you like to have vertical lines. For horizontal lines are available many options:

enter image description here

With employing the tabularray package all tables showed are simple to write. However, beside showing examples, is simple to make other combinations ...

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage{tabularray}

\begin{document}
    \begin{table}[ht!]
    \centering
\begin{tblr}{hlines,
             colspec={c|cc|cc|cc},
             }
    \hline
A   & \SetCell[c=2]{c}  B 
        &   &  \SetCell[c=2]{c} C 
                &   &  \SetCell[c=2]{c} D 
                        &       \\
A   & B & C & D & E & F & G     \\
A   & B & C & D & E & F & G     \\
\end{tblr}
    \end{table}
    
or
    \begin{table}[ht!]
    \centering
\begin{tblr}{hline{1,Z} = 1pt, hline{2-Y}=0.2pt,
             colspec={c|cc|cc|cc},
             }
A   & \SetCell[c=2]{c}  B
        &   &  \SetCell[c=2]{c} C
                &   &  \SetCell[c=2]{c} D
                        &       \\
A   & B & C & D & E & F & G     \\
A   & B & C & D & E & F & G     \\
\end{tblr}
    \end{table}
    
or
    \begin{table}[ht!]
    \centering
\begin{tblr}{hline{1,Z} = 1pt, hline{2}=0.6pt, hline{3-Y}=0.2pt,
             colspec={c|cc|cc|cc},
             }
A   & \SetCell[c=2]{c}  B
        &   &  \SetCell[c=2]{c} C
                &   &  \SetCell[c=2]{c} D
                        &       \\
A   & B & C & D & E & F & G     \\
A   & B & C & D & E & F & G     \\
\end{tblr}
    \end{table}

or
    \begin{table}[ht!]
    \centering
\begin{tblr}{hline{1,Z} = 1pt, hline{2}=0.6pt, hline{3-Y}=0.2pt,
             vlines,
             cells={c},
             }
A   & \SetCell[c=2]{c}  B
        &   &  \SetCell[c=2]{c} C
                &   &  \SetCell[c=2]{c} D
                        &       \\
A   & B & C & D & E & F & G     \\
A   & B & C & D & E & F & G     \\
\end{tblr}
    \end{table}
\end{document}
Related Question