tags:

views:

27

answers:

0

I've got the following table:

\begin{table}[hbtp]
    \caption{Autocompletion example}
    \begin{tabular}{c|l@{}@{}l}
          & \multicolumn{2}{c}{A} \\
        \hline
        1 & \multicolumn{2}{l}{test} \\
        2 & te & \cellcolor{black}{\color{white}st} \\
    \end{tabular}
\end{table}

It's structured like this to make the second and third columns flow together, because I want to show the string "test" normally formatted and then with the color of the two last characters inverted. However, when rendering this the black background of the last cell extends something like 1 em to the left and right of the cell contents, blacking out the "e" in the bottom "te" cell. Any idea how to correct this, or how to otherwise color part of a word differently from the rest without any margin or padding?

Edit: Another option is to use two columns and te\colorbox{black}{\textcolor{white}{st}}, but this adds about 1 en character padding (the separator comes out as newline if copied from the PDF).

Edit: \fboxsep seems to be a step in the right direction, but now the black box is too small to contain the text: te\setlength{\fboxsep}{0ex}\colorbox{black}{\textcolor{white}{st}}