8

Are there known issues with the appearance of white text on black background?

When I use several \hline in a table I get different appearances for the lines. It could appear as normal or weak or entirely missing. Only when I magnify to about 400% do I see the lines consistently.

Assuming this is a hardware issue I tried on a different monitor and same thing showed up. I tried the booktabs package to get custom thickness for the lines but that package puts a band of space around its \hrule causing disconnected appearance if you have a vertical rule. (booktabs discourages vertical rules in a table.)

(Final Edit: I eventually agreed with booktabs, gave up on vertical rule, and got consistent looking white rules on black ground for a table.)

Sample code would be as in white text on black background in entire table:

\documentclass[11pt,letterpaper]{article}
\usepackage[table]{xcolor}
\usepackage{array}
\begin{document}
\begin{table}[H]
  \caption{Caption}
  \label{Table1}
  \begin{center}
    \arrayrulecolor{white}
    \newcolumntype{B}{>{\columncolor{black}\color{white}}c}
    \begin{tabular}{  B  l   | B  p{6in}   }
      \hline\hline
      Text 1 & Text 2 \\
      \hline\hline
      Text 3 & Text 4 \\
      \hline
    \end{tabular}
  \end{center}
\end{table}
\end{document}
11
  • How do they look when printed?
    – qubyte
    Apr 17, 2012 at 10:12
  • 3
    That usually a zooming issue of the PDF viewer. Adobe Acrobat Reader for example shows certain line with variable thickness at different zoom levels. E.g. the vertical lines of a rectangle can be sometimes thicker or thinner than the horizontal ones. Sometimes thinner lines are not shown at all with certain zoom levels. Also, background color is usually a sort of fill, which can be overlapping with rules in the neighborhood. This has to do AFAIK with the drawing and zooming rules followed by the PDF viewer. We already had a couple of similar questions like this here. Apr 17, 2012 at 10:12
  • 3
    General note: The common format for package names here is `packagename` and they should be linked to its webpage on CTAN, not to a PDF on a specific mirror, i.e. http://www.ctan.org/pkg/packagename. No biggy. Apr 17, 2012 at 10:18
  • 1
    In addition to what @MartinScharrer said, try to turn off all kinds of "smoothing" features in the reader settings. Those visual optimizations can make small things disappear. Apr 17, 2012 at 10:27
  • 3
    possible duplicate of Box border lines not showing properly on PDF
    – qubyte
    Apr 17, 2012 at 10:32

1 Answer 1

5

I guess this comes from the fact that the black filling and the white lines are treated differently by the PDF reader, which assumes that the black filling is more important than the white lines, presumably treating the black filling similarly to how text would be treated usually.

When using TikZ to draw the table (based on TikZ matrix as a replacement for tabular), this problem doesn't appear. That approach takes more work (you'll have to set the column widths by hand), so it might well not be feasible for your needs, but if it's just for a simple table that needs to display well on screen at all zoom levels, it might do:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}[
    table/.style={
        minimum height=1.5em,
        matrix of nodes,
        row sep=-\pgflinewidth,
        column sep=-\pgflinewidth,
        text depth=0.5ex,
        text height=2ex,
        nodes in empty cells
    }
]


\matrix [
    table,nodes={
        text width=0.5em,
        draw=white,
        text=white,
        fill=black
    },
    column 2/.style={nodes={text width=2em}},
    column 3/.style={nodes={text width=6em}},
    row 1/.style={nodes={text depth=2\baselineskip+0.5ex}},
    row 2/.style={nodes={text depth=\baselineskip+0.5ex}}
]
{
0   &ABC  & This is a long line that will wrap around \\
1   &DEF  & |[align=right]| Woo, right aligned! \\
2   &GHI  & 9 \\
};
\end{tikzpicture}
\end{document}
3
  • Thanks. Can you include a paragraph column, as in p{2in}, in the table?
    – Maesumi
    Apr 17, 2012 at 13:24
  • @Maesumi: You can, but you'll have to set the text depth for that row manually. Again, this might well be more work than you're willing to do.
    – Jake
    Apr 17, 2012 at 13:57
  • 1
    How do I choose NOT to draw certain lines? For example suppose I do not want the left line or the right line (which bound the table). And, how do I draw a double line, for example under the first row?
    – Maesumi
    Apr 25, 2012 at 22:19

You must log in to answer this question.

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