我有一个tcolorbox
带有一些文本的文本框,我想用它wrapfig2
来包装框内的两张图片,两张图片都被文本包围,一个图片位于框的左上角,另一个位于框的右下角。我成功地包装了第一个,但我很难包装第二个,因为它打印在框外,而它的代码在框内。我在这里缺少什么,我该如何实现我想要的?
% !TeX program = lualatex
\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage[no-math]{fontspec}
\defaultfontfeatures{Scale=MatchLowercase}\defaultfontfeatures[\rmfamily]{Scale=1.1}
\setmainfont{STIX Two Text}
\usepackage[english]{babel}
\usepackage{graphicx,blindtext,wrapfig2}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcolorbox}[]
\begin{wrapfigure}[9]{l}{0.25\textwidth}
\begin{center}
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{2pt}%
\vspace{-6mm}
\fbox{\includegraphics[width=0.2\textwidth]{example-image-a}}
\end{center}
\caption{\footnotesize Image A}
\end{wrapfigure}
\blindtext[3]
\begin{wrapfigure}[9]{r}{0.25\textwidth}
\begin{center}
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{2pt}%
\vspace{-6mm}
\fbox{\includegraphics[width=0.2\textwidth]{example-image-b}}
\end{center}
\caption{\footnotesize Image B}
\end{wrapfigure}
\end{tcolorbox}
\end{document}
答案1
你总是需要给出数字前段落文本,以便可以设置段落形状。
% !TeX program = lualatex
\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage[no-math]{fontspec}
\defaultfontfeatures{Scale=MatchLowercase}\defaultfontfeatures[\rmfamily]{Scale=1.1}
\setmainfont{STIX Two Text}
\usepackage[english]{babel}
\usepackage{graphicx,blindtext,wrapfig2}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcolorbox}[]
\begin{wrapfigure}[9]{l}{0.25\textwidth}
\begin{center}
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{2pt}%
\vspace{-6mm}
\fbox{\includegraphics[width=0.2\textwidth]{example-image-a}}
\end{center}
\caption{\footnotesize Image A}
\end{wrapfigure}
Hello, here is some text without a meaning. This text should show what a printed text
will look like at this place. If you read this text, you will get no information. Really? Is there
no information? Is there a difference between this text and some nonsense like ``Huardest
gefburn''? Kjift -- not at all! A blind text like this gives you information about the selected
font, how the letters are written and an impression of the look. This text should contain all
letters of the alphabet and it should be written in of the original language. There is no need
for special content, but the length of words should match the language. Hello, here is some
text without a meaning. This text should show what a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there no information? Is there
a difference between this text and some nonsense like ``Huardest gefburn''? Kjift -- not at
all! A blind text like this gives you information about the selected font, how the letters are
written and an impression of the look. This text should contain all letters of the alphabet and
it should be written in of the original language. There is no need for special content, but the
length of words should match the language. Hello, here is some text without a{\parfillskip=0pt\par}
\begin{wrapfigure}[9]{r}{0.25\textwidth}
\begin{center}
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{2pt}%
\vspace{-6mm}
\fbox{\includegraphics[width=0.2\textwidth]{example-image-b}}
\end{center}
\caption{\footnotesize Image B}
\end{wrapfigure}
\noindent meaning. This
text should show what a printed text will look like at this place. If you read this text, you will
get no information. Really? Is there no information? Is there a difference between this text
and some nonsense like ``Huardest gefburn''? Kjift -- not at all! A blind text like this gives
you information about the selected font, how the letters are written and an impression of the
look. This text should contain all letters of the alphabet and it should be written in of the
original language. There is no need for special content, but the length of words should match
the language.
\end{tcolorbox}
\end{document}