2

Don't worry its not a problem of $ being a special character (or at least I think). For some reason the $ that is supposed to show up next to the total on the last line does not. Removing either the \cellcolor commands or the @{} in the tubularx definition makes it show up. Why is this happening and how can I get my $ back?

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{\linewidth}{Xc@{}r}
  TEST && 1000 \\
  ANOTHER TEST && 5000 \\
  \multicolumn{1}{r}{TOTAL} & \cellcolor{blue!25!white} \textdollar & \cellcolor{blue!25!white} 6000\\
\end{tabularx}
\end{document}
  • 2
    It is covered by the padding in the last column: colortbl apply a padding notwithstanding a @{} specification. – egreg Jul 11 '16 at 21:06
  • @egreg Is there a way to get no padding and still have colored cells? – carloabelli Jul 11 '16 at 21:06
  • Is there something preventing you from keeping the middle column empty and writing \cellcolor{blue!25!white}\textdollar 6000 in the final column? – Mico Jul 11 '16 at 21:11
  • @Mico I would love for the dollar sign to be left aligned while the amount right aligned. Perhaps there is a better way? – carloabelli Jul 11 '16 at 21:13
  • @cabellicar123 - \cellcolor{blue!25!white}\textdollar\hspace*{\fill} 6000 should work, right? – Mico Jul 11 '16 at 21:14
  • @Mico I seem to be getting strange results when using that. – carloabelli Jul 11 '16 at 21:17
  • "seem to be getting strange results" is not exactly specific, let alone actionable. Could you elaborate? – Mico Jul 11 '16 at 21:18
  • @Mico My apologies it is rather unspecific. I modified the number in the first row of the table to be 1000000000 to better demonstrate the issue. The $ is placed too far right. The color seems to start in the correct place, but does not cover the entire cell (the last 0 in 6000 is not covered with color). – carloabelli Jul 11 '16 at 21:21

1 Answers1

3

\cellcolor applies a padding and so your dollar sign ends up below this padding and so it's invisible.

A variant of an answer by Herbert seems to solve the issue. I reduced the width just to make a smaller picture; the figures are incorrect, of course.

\documentclass{article}

\usepackage[table]{xcolor}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{.75\textwidth}{Xc>{\kern-2\tabcolsep}r}
  TEST && 10000000 \\
  ANOTHER TEST && 5000 \\
  \multicolumn{1}{r}{TOTAL} & \cellcolor{blue!25!white}\textdollar
& \cellcolor{blue!25!white}6000\\
\end{tabularx}
\end{document}

enter image description here

egreg
  • 1,121,712