1

I have the following code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

\begin{document}

\begin{table}
    \centering
    \caption{Example}
    \begin{tabularx}{0.4\textwidth}{lll}
        \hline
        \rowcolor{yellow}
        A & C & E... \\
        B & D & F...... \\
        \hline
    \end{tabularx}
\end{table}

\end{document}

And the output is like this: enter image description here

Why the yellow row color is not filling the entire row, but only the part which has some text in it ?

Thank you

1
  • At least one of the columns should employ the X column type.
    – Mico
    Commented Nov 28, 2017 at 20:42

1 Answer 1

2

The tabularx package provides the X column type. If you want the tabularx environment to take up the specified width, at least one of the columns must employ the X column type (or a column type that's derived from X).

For instance:

\begin{tabularx}{0.4\textwidth}{XXX}

will ensure that the three columns are equally wide.

You must log in to answer this question.

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