Quebrando texto em um fcolorbox?

Quebrando texto em um fcolorbox?

Estou usando o pacote "color" para ter uma caixa de texto verde com texto preto e meu código é -

\textbf{\fcolorbox{black}{green!30}{black text on a boxed green background}}

Como posso fazer com que ele enrole as linhas, por favor?

Se não for possível agrupar com 'fcolorbox', qual comando teria o mesmo efeito e seria agrupado, por favor?

Responder1

Sugiro um dos meus pacotes favoritos:tcolorbox

\documentclass{article}


\usepackage{tcolorbox}
% A new `\tcbox` command



\newtcbox{\highlight}[0]{boxsep=0pt,left=0pt,top=0pt,bottom=0pt,right=0pt,boxrule=0pt,arc=0pt,auto outer arc,colback=green,width=6cm}


\begin{document}

\highlight{black text on a boxed green background}

\begin{tcolorbox}[width=6cm,colback=green]
black text on a boxed green background
\end{tcolorbox}

\begin{tcolorbox}[width=6cm,colback=green,boxrule=5pt]
black text on a boxed green background
\end{tcolorbox}

\begin{tcolorbox}[width=6cm,colback=green,arc=0pt,auto outer arc]
black text on a boxed green background
\end{tcolorbox}


\end{document} 

insira a descrição da imagem aqui

Responder2

\fcolorboxé como \fboxou \mboxe faz uma caixa horizontal (LR), então você precisa

\textbf{\fcolorbox{black}{green!30}{%
   \parbox{3cm}{black text on a boxed green background}}}

substituindo 3cmpela largura que você precisar.

informação relacionada