有谁知道如何才能wrapfigure
与易碎的 tcolorbox 玩得好吗?
以下是两组插图和代码示例。第一个示例使用tcolorbox
和breakable
的设置wrapfigure
。它显示tcolorbox
在第一页的末尾按预期换行(快照是第 1 页的左下角和第 2 页的左上角)。
然后,第二个示例启用了wrapfigure
。tcolorbox
编译器认识到 应该tcolorbox
在页面末尾中断,但它并没有像人们希望的那样执行此操作。(第二个示例中的代码仅在 的定义上有所不同\sidebox
:wrapfigure
代码被取消注释,因此对宽度进行了微小的调整tcolorbox
。)
有什么方法可以获得期望的行为吗?
抱歉,必须lipsum
在 MWE 中重新定义,但它必须具有正确的长度,否则您将无法看到问题。
第一个插图如下:
第二幅图如下:
第一个插图的代码:
\documentclass[letterpaper,12pt]{memoir}
\usepackage[english]{babel}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{wrapfig}
\newcommand{\sidebox}[1]%
{%
% \setlength{\intextsep}{0pt}%
% \begin{wrapfigure}{l}{3cm}%
% \begin{tcolorbox}[width=\linewidth,valign=center,breakable]%
\begin{tcolorbox}[width=0.2\linewidth,valign=center,breakable]%
#1%
\end{tcolorbox}%
% \end{wrapfigure}%
}%
\newcommand{\mylipsum}{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.}
\begin{document}
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\mylipsum
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\mylipsum
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\mylipsum
\end{document}
第二幅插图的代码:
\documentclass[letterpaper,12pt]{memoir}
\usepackage[english]{babel}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{wrapfig}
\newcommand{\sidebox}[1]%
{%
\setlength{\intextsep}{0pt}%
\begin{wrapfigure}{l}{3cm}%
\begin{tcolorbox}[width=\linewidth,valign=center,breakable]%
% \begin{tcolorbox}[width=0.2\linewidth,valign=center,breakable]%
#1%
\end{tcolorbox}%
\end{wrapfigure}%
}%
\newcommand{\mylipsum}{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.}
\begin{document}
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\mylipsum
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\mylipsum
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\mylipsum
\end{document}
答案1
这看起来像是 paracol 的工作!一个缺点是您必须手动拆分最后一段以换行。在此处搜索\splitpar
和\continuepar
。
\documentclass[letterpaper,12pt]{memoir}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{paracol}
\newcommand{\sidebox}[1]%
{%
\begin{tcolorbox}[width=\linewidth,valign=center,breakable]% or \columnwidth
#1%
\end{tcolorbox}%
}%
\begin{document}
\setcolumnwidth{3cm}
\begin{paracol}{2}
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\sidebox{the quick brown fox jumps over the lazy dog and jumps again and again and again}
\switchcolumn
\lipsum[1-4]
\end{paracol}
\end{document}