Horizontal lines in nested tabular environment

Something like this:

enter image description here

For this you need to eliminate table column separation in column in which you nested table. This is done with use of @{}:

\begin{table}
\centering
\begin{tabular}{ |c|@{}c@{}| }% <-- aded @{}
\hline
no test & no test \\
\hline
no test & 
    \begin{tabular}{c|c} D1 & 1.23 \\ \hline D2 & 1.23 \\ \end{tabular} \\
\hline
\end{tabular}
\end{table}

Just replace in the main table preamble c with @{}c@{} for each column which contains a nested tabular. Note this requires the array package.

I also improved the table loading the cellspace package, which defines minimal vertical padding between a row and the above and below cells in columns with a specifier prefixed by the letter S:

\documentclass[11pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{array}

\begin{document}

\begin{table}
\centering
\begin{tabular}{ |c|@{}c@{}| }
\hline
no test & no test \\
\hline
no test & \begin{tabular}{c|c} D1 & 1.23 \\ \hline D2 & 1.23 \\ \end{tabular} \\
\hline
\end{tabular}
\end{table}

\end{document}

enter image description here

Tags:

Tables