Graphics, Figures & TablesColor declaration causes line break in tabularx

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
skip
Posts: 4
Joined: Wed Sep 30, 2009 12:19 pm

Color declaration causes line break in tabularx

Post by skip »

I'm using tabluarx and the following code:

Code: Select all

\begin{tabularx}{\columnwidth}{|X|X|}
{\bf 23 September 2009 }&{\color{DarkGray}\bf OVERALL SCORE ACHIEVED}\hfill{\bf\color{DarkGray}85\%}
\end{tabularx}
causes a line break on the right hand cell. The left and cell (23 Septmeber 2009) is correct but the contents of the right hand (OVERALL...) cell start on the next line in their cell. The culprit seems to be the first \color declaration on the OVERALL text before the hfill. If I remove it everything is rendered on the same line in both cells.

Any idea why the \color declaration is doing that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Color declaration causes line break in tabularx

Post by Stefan Kottwitz »

Hi skip,

you could use \textcolor instead of \color to avoid this line break.

Stefan
LaTeX.org admin
skip
Posts: 4
Joined: Wed Sep 30, 2009 12:19 pm

Re: Color declaration causes line break in tabularx

Post by skip »

Thanks, that worked like a charm.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Color declaration causes line break in tabularx

Post by Stefan Kottwitz »

Btw. \bf is an obsolete LaTeX 2.09 command, use \bfseries or \texbf instead, see LaTeX2e font selection.

Stefan
LaTeX.org admin
Post Reply