I want to produce documents where every paragraph, equation, and other visually distinct part of the document is highlighted with its own background color (e.g. equations are highlighted in blue, tables in red, headers in green, etc.)

To add to the challenge, I want to apply this technique to thousands of pre-existing latex documents; solutions that require complex changes to existing latex may not be practical.

I posed this question as a paragraph coloring question because I suspect that might be an easy way to do what I want. But any method of recovering the bounding boxes associated with each command that produces page content would work. For instance, there may be a way to recover the page locations of content generated from latex commands from the DVI files or the latex log.

My ultimate goal is to create a data set to support research into automated document processing: I want to create algorithms that can parse an image of a page into its structural components without the need for the original mark-up. I require a mapping between latex mark-up and the locations of the resulting content on the page to train and evaluate algorithms.

  • I am not sure I understand your question but if you try pdflatex -jobname=myfile \RequirePackage{color}\everydisplay{blue}\input{\jobname} equations in your file will be highlighted in blue.
    – touhami
    Feb 19, 2016 at 20:11
  • Thanks! Changing the text color for different parts of the document would satisfy my need. I played with the everyhook package a little bit and I don't see how I could use it to change the color of things like \author, \title, \section, \caption, etc. Is there some way I can easily add different colors to these? Feb 24, 2016 at 21:14
  • so all what you need is to highlight some stuf can you list this commands?
    – touhami
    Feb 24, 2016 at 21:27

1 Answer 1


I'm doing a coursework at university. The goal is to extract text from a book. I also need to extract the page structure: headers, paragraphs, etc. I generate a dataset in latex and log bounding boxes:

       "x":"\the\dimexpr \Ax sp -\parindent\relax",
       "y":"\the\dimexpr \Ay sp -\parindent\relax",

I wish you to share your results if you can. Thanks you!

You must log in to answer this question.

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