I couldn't find a question that answers this. I'm new to tex so I'm trying to figure out how the spacing works. Basically I want the following to to appear as if it's one word with different highlighting:

My preamble:

\documentclass[12pt,a4paper]{article} % din a4, 11 pt, one sided



My text:


The output (PDF):

initial tex output

Removing the carriage returns between tags helps the actual white space, but not padding between words:


enter image description here

Again I want this to just appear as if it is one word with different highlight colors. Ideally it would be across many lines as shown in the first example, because this will eventually be a long string generated by Jinja. Any suggestions? Thanks in advance.

  • Likely the more powerfulltcolorbox could help to control the (unwanted) padding.
    – Jhor
    Jun 29, 2018 at 21:04

1 Answer 1


You need to comment out (or not add) the linebreaks which are inter-word spaces, and \colorbox adds padding of \fboxsep around its content so you can add


You must log in to answer this question.

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