
私のコードは次のとおりです:
\documentclass{article}
\usepackage[table]{xcolor}
\definecolor{background}{rgb}{1,0.62502,0}
\usepackage{wrapfig}
\setlength\intextsep{0pt}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{wrapfigure}{l}{6.5cm}
\noindent
\fcolorbox{background}{background}{
\begin{minipage}{0.5\textwidth}
Some text. \lipsum[4]
%\fcolorbox{frame color}{box background color}{text}
\end{minipage}}
\end{wrapfigure}
\lipsum[1]
\end{document}
つまり、次のようになります。
これにほぼ満足していますが、minipage 環境 (さらに wrapfigure 環境) のテキスト行が周囲のテキストと水平に揃っていないことは明らかです。wrapfig 環境内のテキスト行を周囲のテキストと水平に揃える方法はありますか?
内部のミニページ環境を削除したら、テキストを水平方向に揃える作業は完了したと思います。ただし、折り返されたテキストの背景色を維持するために、ミニページ環境は保持しておきたいと思います。
答え1
オプションの minipage パラメータを使用して、最初の (上部の) ベースラインとの位置合わせを実現します。\begin{minipage}[t]{0.5\textwidth}
このオプションの引数の位置は、ミニページが周囲の素材と垂直に揃う方法を制御します。
\fboxsep
フレームから囲まれたボックスまでの距離を設定します。デフォルトは 3pt です。
で0ptに設定します\setlength{\fboxsep}{0pt}
。
\documentclass{article}
\usepackage[table]{xcolor}
\definecolor{background}{rgb}{1,0.62502,0}
\usepackage{wrapfig}
\setlength\intextsep{0pt}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{wrapfigure}{l}{6.5cm}
\noindent
\setlength{\fboxsep}{0pt}% added <<<<<<<<<<<<<<
\fcolorbox{background}{background}{%
\begin{minipage}[t]{0.5\textwidth} % changed <<<<<<<<<<<<
Some text. \lipsum[4]
%\fcolorbox{frame color}{box background color}{text}
\end{minipage}}
\end{wrapfigure}
\lipsum[1]
\end{document}