
私はパッケージ「color」を使用して、黒いテキストの緑のテキスト ボックスを作成しています。コードは次のとおりです。
\textbf{\fcolorbox{black}{green!30}{black text on a boxed green background}}
行を折り返すにはどうしたらいいでしょうか?
「fcolorbox」で折り返すことができない場合、どのコマンドが同じ効果を持ち、折り返すのでしょうか?
答え1
私のお気に入りのパッケージの 1 つをお勧めします。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}
答え2
\fcolorbox
\fbox
はまたはのように\mbox
水平(LR)ボックスを作成するので、
\textbf{\fcolorbox{black}{green!30}{%
\parbox{3cm}{black text on a boxed green background}}}
3cm
必要な幅に置き換えます。