¿Envolver texto en un fcolorbox?

¿Envolver texto en un fcolorbox?

Estoy usando el paquete "color" para tener un cuadro de texto verde con texto negro y mi código es:

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

¿Cómo puedo hacer que ajuste las líneas, por favor?

Si no se puede ajustar con 'fcolorbox', ¿qué comando tendría el mismo efecto y se ajustaría, por favor?

Respuesta1

Te sugiero uno de mis paquetes 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} 

ingrese la descripción de la imagen aquí

Respuesta2

\fcolorboxes como \fboxo \mboxy forma un cuadro horizontal (LR), por lo que necesitas

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

reemplazando 3cmpor el ancho que necesites.

información relacionada