When I put an \hfill
in a tabular row colored using the colortbl
package, the coloring does not extend to what I would expect the end of the row to be.
For example, the code:
\documentclass{article}
\usepackage{colortbl}
\usepackage{xcolor}
\begin{document}
\begin{tabular}{c}
\rowcolor{black}\textcolor{white}{Sample Text}\\
\rowcolor{black}\hfill\textcolor{white}{More Text}\\
\end{tabular}
\end{document}
produces this output:
I would expect it to produce something like this:
I'm guessing that the problem is that using \hfill
is somehow changing the length of the line. Is that the case? And, if not, why does the length of the coloring change when I use \hfill
?
Best Answer
You could use
\hspace{0pt plus 1filll}
that would override the\hfill
at the end of the cell, but this would confuse the coloring as the example shows. Better stating right alignment with\multicolumn
:Keep in mind that the reverse would require two glues (one infinite and the other zero) because a glue at the end of the cell is removed (by
\unskip
).