I have a large (13x13) table in which I need to highlight a subset of cells. I know that I can set a background color to those cells using colortbl or xcolor. But I need to highlight the table without using color (it is a scientific paper, and the table should communicate its purpose without assuming the reader will have access to a color printer). Is there a way to do so? For example a circle around the cell?

  • 4
    You can consider using a gray background to highlight it. You can play around with different shades of gray to see what is visible in print. Usually something around 80% while looks good as a background.
    – Aditya
    Nov 3 '10 at 3:36

Generally I agree with lockstep that circling might not be the best way to highlight text. In addition to his suggestions, you could also try using a light gray background.

Having said that, here is a way to circle text using TikZ:



    \tikz[overlay,remember picture] 
        \node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
    \tikz[overlay,remember picture]
        \node (marker-\arabic{nodemarkers}-b) at (0,0){};%
    \tikz[overlay,remember picture,inner sep=2pt]
        \node[draw,ellipse,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};%


    Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\\hline
    bla   & bla   & \circletext{bla}   & bla   & bla   & bla \\
    bla   & bla   & bla   & bla   & bla   & bla \\ 
    ble   & ble   & ble   & bla   & \circletext{bla}   & bla \\ 
    bla   & bla   & bla   & bla   & bla   & bla \\ \hline



The \circletext command defines a node to the left and right of the text and then fits an ellipse around them. More fanciful graphics are of course possible, this is a rather basic example (since I do not know what your table looks like). Two LaTeX runs are necessary to have everything show up in the right place.

Edit: Here is an example of how to mark arbitrary blocks. Ellipses don't look good with large blocks, so it is using rounded rectangles instead:



    \tikz[overlay,remember picture] 
        \node (marker-#1-a) at (0,1.5ex) {};%
    \tikz[overlay,remember picture] 
        \node (marker-#1-b) at (0,0) {};%
    \tikz[overlay,remember picture,thick,dashed,inner sep=3pt]
        \node[draw,rounded rectangle,fit=(marker-#1-a.center) (marker-#1-b.center)] {};%


    Col 1 & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 \\\hline
    bla   & bla   & \marktopleft{c1}bla   & bla   & bla   & bla \\
    bla   & bla   & bla   & bla   & bla   & bla \\ 
    ble   & ble   & ble   & bla   & bla\markbottomright{c1}   & bla \\ 
    bla   & bla   & bla   & bla   & bla   & bla \\ 
    bla   & \marktopleft{c2}bla   & bla   & bla   & bla\markbottomright{c2}   & bla \\ \hline



  • I agree that circles around single cells don't look too bad, but the OP mentioned " a subset of cells" which I perceived as a multi-cell area.
    – lockstep
    Nov 3 '10 at 7:13
  • @lookstep: it seems that circling single cells is what @carlosdc wanted. Adapting to blocks is trivial though (as long as the cells are the same size -- otherwise it is probably easiest to use a tikz matrix as Matthew suggested.)
    – Caramdir
    Nov 4 '10 at 0:37
  • @Caramdir: this is one truly useful answer, I used variations of it several times in the last few weeks. Thanks a lot! Dec 31 '11 at 17:11
  • Although off-topic, I really need to know (otherwise I can't sleep): why are %s written at the line ending in so many TeX snippets?
    – letmaik
    Sep 9 '12 at 7:33

I cannot offer a "TeXnical" answer, only typographical advice: A circle put around a subset of cells within a large table may look like a superimposed figure unrelated to the table - in other words, it may be very confusing. Instead, I would try one of the following:

  • Draw a rectangle around the particular cells (may still not look pretty);

  • Use a raster as background;

  • Typeset the cell content in bold or italic.


I think replacing the matrix with a TiKZ matrix would allow you to fit paths around groups of cells.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.