Using pdfliteral, one can color text like the following:

      w1_prev = node.new("whatsit","pdf_literal")
      w1_prev.data = "q 1 0 0 rg"
      w1_prev.mode = 1

      w2_prev = node.new("whatsit","pdf_literal")
      w2_prev.data = "Q"
      w2_prev.mode = 1

      node.insert_after(prev_line.prev,prev_line.prev,w1_prev) --color text between prev_line.prev...
      node.insert_before(prev_line,prev_head,w2_prev) -- and prev_head

Is there a code similar to q 1 0 0 rg which highlights text instead of coloring the letters?

  • By 'highlight', do you mean a 'marker-pen' like background?
    – Joseph Wright
    Sep 19, 2011 at 9:34
  • @JosephWright yes, indeed.
    – raphink
    Sep 19, 2011 at 9:34

1 Answer 1


This question is more appropriate on a PDF q&a site :)

You can draw PDF boxes with the code I posted in my answer to the one letter word problem. Just be sure to put the pdf_literal at the beginning of the text, so the text is on top of that box.

  • Right, I know about the boxes (from reading and using your code), but what I would like to achieve is to highlight the text :-)
    – raphink
    Sep 19, 2011 at 9:49
  • 1
    At least at the TeX level, 'highlighting' is always done by boxing material up, as you can only set the background of a box, not of particular text.
    – Joseph Wright
    Sep 19, 2011 at 10:31

You must log in to answer this question.

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