4

Inside a tabularx environment I nested a two column width tabular which doesn't fit into the space completely. There are indentations on each side. How can I remove them?

MWE:

\documentclass[12pt,a4paper]{article}
\usepackage{tabularx}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\begin{tabularx}{\linewidth}{c|X|X}
row & row & row\\ \hline
row & \multicolumn{2}{l|}{\noindent\begin{tabular}{>{\hsize=2\hsize}X}ROW:\\ \blindtext\\ \end{tabular}}\\
\end{tabularx}
\end{document}

Example

1
  • The distance comes from the \tabcolsep. It's added twice (from the outer and the inner table). Do you really need nested tables?
    – someonr
    Dec 8, 2013 at 22:16

1 Answer 1

5

You're not taking into account the horizontal spacing buffering the cells.

Try something along these lines:

\documentclass[12pt,a4paper]{article}
\usepackage{tabularx}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\begin{tabularx}{\linewidth}{c|X|X}
row & row & row\\ \hline
row & 
\multicolumn{2}{l|}{%%
   \noindent
   \begin{tabular}{@{}>{\hsize=\dimexpr2\hsize+4\tabcolsep\relax}X@{}}
     ROW:      \\ 
     \blindtext\\ 
   \end{tabular}
  }\\
\end{tabularx}
\end{document}

enter image description here

What I've done here is adjust the \hsize to take into account the \tabcolsep. Also, I've added @{} to remove such extra padding around the inner most tabular environment.

Though what follows is most likely not at all what you want, I hope it illustrates a bit better the effect of @{} as I used it.

Leaving in the right most vertical line, I can better illustrate this use of @{} within the \multicolumn{2}{l@{}|} where the effect is

\documentclass[12pt,a4paper]{article}
\usepackage{tabularx}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\begin{tabularx}{\linewidth}{c|X|X}
row & row & row\\ \hline
row & 
\multicolumn{2}{l@{}|}{%%
   \noindent
   \begin{tabular}{@{}>{\hsize=\dimexpr2\hsize+4\tabcolsep\relax}X@{}}
     ROW:      \\ 
     \blindtext\\ 
   \end{tabular}
  }\\
\end{tabularx}
\end{document}

enter image description here

After removing the last vertical line, the effect is as follows, which is perhaps what you were hoping for:

enter image description here

You must log in to answer this question.

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