使用命令时出现问题\colorbox
。如您在示例及其输出中看到的那样,中的语句\colorbox
未正确换行。对此有什么建议吗?
\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}
Elsevier tex 软件包现已可用这里。
更新
除了 SoundsOfSilence 的解决方案(这是一个可行的解决方案)之外,我发现\usepackage{soul}
另一个解决方案\hl{the text}
更好,并且支持换行。更多信息可用这里。
答案1
例如,您可以引入一个\parbox
宽度为的,或者使用一个解决方案。0.9\textwidth
tcolorbox
可以使用以下方法调整间距各种各样的选项
\documentclass[review]{elsarticle}
\usepackage{xcolor}
\usepackage{tcolorbox}
\tcbset{width=0.9\textwidth,boxrule=0pt,colback=red,arc=0pt,auto outer arc,left=0pt,right=0pt,boxsep=5pt}
\begin{document}
\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}{\parbox{0.9\textwidth}{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!}}
\begin{center}
\begin{tcolorbox}
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{tcolorbox}
\end{center}
\end{abstract}
\end{document}