4

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:

enter image description here

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:

enter image description here

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.

4

Something like this:

enter image description here

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.