There is a problem with using \colorbox
command. As you can see in the example and its output, the statements in the \colorbox
doesn't correctly wrapped. Is there any suggestion for that?
\documentclass[review]{elsarticle}
\usepackage{color}
\begin{document}
\begin{frontmatter}
\begin{abstract}
This is an example to show that without using the colorbos command in latex, the text is correctly wrrapped as the formatting suggests.
\colorbox{red}{I am trying to understand how the colorbox command works in latex. As you can see, adding the a phrase inside the colorbox command causes the text to exceed the page boundary. However, I want to see a wrap!}
\end{abstract}
\end{frontmatter}
\end{document}
The Elsevier tex package is available here.
UPDATE
Apart from the solution by SoundsOfSilence, which is a working solution, I found that \usepackage{soul}
and \hl{the text}
is much better and supports line breaking. More info is available here.
Best Answer
You could introduce a
\parbox
, of width, say,0.9\textwidth
, for example or use atcolorbox
solution.Spacings could be adjusted by using various options