
Ich verwende das Paket „color“, um ein grünes Textfeld mit schwarzem Text zu erhalten, und mein Code lautet:
\textbf{\fcolorbox{black}{green!30}{black text on a boxed green background}}
Wie kann ich es bitte dazu bringen, Zeilen umzubrechen?
Wenn ein Umbruch mit „fcolorbox“ nicht möglich ist, welcher Befehl hätte dann bitte die gleiche Wirkung und würde einen Umbruch durchführen?
Antwort1
Ich schlage eines meiner Lieblingspakete vor: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}
Antwort2
\fcolorbox
ist wie \fbox
oder \mbox
und ergibt eine horizontale (LR) Box, also brauchst du
\textbf{\fcolorbox{black}{green!30}{%
\parbox{3cm}{black text on a boxed green background}}}
Ersetzen Sie es 3cm
durch die Breite, die Sie benötigen.