# Horizontal lines in nested tabular environment

I currently have this table:

\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}


Giving:

hline in the nested tabular does not span the entire cell width.

Of course multirow/multicolumn would be a choice. However, this is a "mutable" table, to which I will need to add "sub-rows" each time new data arrives, but I do not know in advance where. So, it could become something like:

For such purpose, multirow/multicolumn seems that would require constantly changing their row/column numbers.

How can this be solved in such a way that minimizes the work each time a new "sub-row" is added?

Thanks.

Something like this:

For this you need to elininate 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}