TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
By 'highlight', do you mean a 'marker-pen' like background? – Joseph Wright Sep 19 '11 at 9:34
@JosephWright yes, indeed. – ℝaphink Sep 19 '11 at 9:34
up vote 1 down vote accepted

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.

share|improve this answer
Right, I know about the boxes (from reading and using your code), but what I would like to achieve is to highlight the text :-) – ℝaphink Sep 19 '11 at 9:49
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 '11 at 10:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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