2

enter image description here

As shown in the image above, when highlighting text with color, we lose the paragraph format and all text goes to a single line. If the paragraph is long enough, the rest of text will even go beyond margins. How can I solve this and get the text to be in the normal format (i.e., actual paragraph) but highlighted?My source code:

\documentclass{IEEEtran}
\usepackage{blindtext}
\usepackage[svgnames]{xcolor}


\begin{document}

\Large
\colorbox{SkyBlue}{The text in colored box overlaps with neighboring column as seen here}   

\normalsize
\Blindtext

\end{document}
2
  • 2
    \colorbox is like \mbox and , as documented, is a horizontal mode box. Jul 17, 2017 at 18:46
  • 1
    see for example the soul package for highlighting Jul 17, 2017 at 19:11

2 Answers 2

3

In LaTeX use the soul package (load xcolor before soul).

\documentclass{article}
\usepackage{multicol}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{soul}
\begin{document}

\begin{multicols}{2}
  \hl{The text in colored box overlaps with neighboring column as seen here}
  \blindtext
\end{multicols}

\end{document}

enter image description here

1

That is super easy in ConTeXt MKIV.

% https://randomdeterminism.wordpress.com/2010/10/31/can-i-borrow-your-highlighter-please/
\definebar
  [highlight]
  [order=background,
   rulethickness=2.5,
   offset=1.25,
   continue=yes,
   color=yellow]

\starttext

\startcolumns[n=2]
  \highlight{The text in colored box overlaps with neighboring column as seen here}
  \input lorem
\stopcolumns

\stoptext

enter image description here

You must log in to answer this question.

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