我是一个相当熟练的乳胶用户,但却偶然发现了超出我经验的格式化挑战。
我正在尝试创建一个自定义的“盒子”浮点数 - 类似于人们在儿童科学书籍(例如 Dorling Kindersley 科学书籍)中看到的内容。
我想在这个浮点数中包含文本和子浮点数,并且希望文本环绕在子浮点数周围。有办法吗?我在网上搜索了很多,但一无所获,所以我想知道是否有一种根本不同的方法来解决这个问题。
理想情况下我想知道:
- 如何在下面的 MWE 中分别围绕标有“换行?”的每个子图单独换行文本。
- 如何环绕一组子图,例如下面 MWE 中的小页面。
欢迎就如何做到这一点或在哪里寻找提供建议。
我已经使用小型页面包含了 MWE,并且没有任何包装功能。
本例中的方法存在以下问题:
- 我希望能够灵活地不是将图形排成一行
- 如果我采用如图所示的排列格式,文本中就会出现断点。
谢谢!
\documentclass{article}
\usepackage{amsmath}
%For use of "\includegraphics"
\usepackage{graphicx}
%For filler text
\usepackage{lipsum}
%For textcolor
\usepackage{xcolor}
%To force figure position and for "\restylefloat"
\usepackage{float}
%To define custom float environments
\usepackage{newfloat}
%For "DeclareCaptionSubtype" below
\usepackage{caption}
%For subfigures
\usepackage{subcaption}
%Wrap text around figures
%\usepackage{wrapfig}
% Set the color of the "shaded" environment
\colorlet{shadecolor}{black!5}
%For use of the "shaded" environment
\usepackage{framed}
%Define the "mybox" environment
\DeclareFloatingEnvironment[
fileext=lob, %An auxiliary file that stores the "list of boxes" (.lob). This abbreviation is user defined and analogous to .lof (list of figures) and .lot (list of tables0.
listname={List of Boxes}, %Title for the TOC list of this type of float
placement={htbp},%All possible placement options
name=Box %Name of float type - to appear in caption
]{mybox} %handle for this float environment
%If you would like the "boxing" float style to be boxed
%Note: \floatstyle applies on all subsequent \newfloat commands
\floatstyle{boxed}
\restylefloat{mybox}
%Announce the "mybox" float type to subcaption and create the subtextbox environment
\DeclareCaptionSubType[alph]{mybox}
\renewcommand\thesubmybox{\alph{submybox}}
%Figure Path
%\newcommand{\FigurePath}{Absolute File Path Here}
%Filler Art
\newcommand{\FillerArt}{example-image}
\begin{document}
\begin{mybox}
\begin{shaded*}
\footnotesize
\begin{center} \textbf{This is a Title}\end{center}
\lipsum[1]
\begin{minipage}[t]{.3\textwidth}
\centering
\begin{submybox}{\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Individual subfloat to wrap.}}
\label{}
\end{submybox}
\end{minipage}
\begin{minipage}[t]{.58\textwidth}
\lipsum[1]
\end{minipage}\\
\begin{minipage}{.3\textwidth}
\begin{submybox}{\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{1 of 2 to wrap as a group.}}
\label{}
\end{submybox}
\begin{submybox}{\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{2 of 2 to wrap as a group.}}
\label{}
\end{submybox}
\end{minipage}
\begin{minipage}[t]{.58\textwidth}
\lipsum[1]
\end{minipage}\\
\begin{minipage}{\textwidth}
\centering
\begin{submybox}{.3\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\end{minipage}
\end{shaded*}
\caption{\textbf{Box Test.}}
\label{box:test}
\end{mybox}
\end{document}
答案1
这不是一个解决方案,而是一个经过一些调整的可执行 MWE。
\documentclass{article}
\usepackage{amsmath}
%For use of "\includegraphics"
\usepackage{graphicx}
%For filler text
\usepackage{lipsum}
%For textcolor
\usepackage{xcolor}
%To force figure position and for "\restylefloat"
\usepackage{float}
%To define custom float environments
\usepackage{newfloat}
%For "DeclareCaptionSubtype" below
\usepackage{caption}
%For subfigures
\usepackage{subcaption}
%Wrap text around figures
%\usepackage{wrapfig}
% Set the color of the "shaded" environment
\colorlet{shadecolor}{black!5}
%For use of the "shaded" environment
\usepackage{framed}
%Define the "mybox" environment
\DeclareFloatingEnvironment[
fileext=lob, %An auxiliary file that stores the "list of boxes" (.lob). This abbreviation is user defined and analogous to .lof (list of figures) and .lot (list of tables0.
listname={List of Boxes}, %Title for the TOC list of this type of float
placement={htbp},%All possible placement options
name=Box %Name of float type - to appear in caption
]{mybox} %handle for this float environment
%If you would like the "boxing" float style to be boxed
%Note: \floatstyle applies on all subsequent \newfloat commands
\floatstyle{boxed}
\restylefloat{mybox}
%Announce the "mybox" float type to subcaption and create the subtextbox environment
\DeclareCaptionSubType[alph]{mybox}
\renewcommand\thesubmybox{\alph{submybox}}
%Figure Path
\newcommand{\FigurePath}{Absolute File Path Here}% see also \graphicspath
%Filler Art
%\newcommand{\FillerArt}{\FigurePath Figure File Here}
\newcommand{\FillerArt}{example-image}
\usepackage{blindtext}
\begin{document}
\begin{mybox}
\begin{shaded*}
\footnotesize
\begin{center} \textbf{This is a Title}\end{center}
\lipsum[1]
\begin{minipage}[t]{.3\textwidth}
\centering
\begin{submybox}[t]{\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Wrap?}}
\label{}
\end{submybox}
\begin{submybox}[t]{\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Wrap?.}}
\label{}
\end{submybox}
\begin{submybox}[t]{\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Wrap?.}}
\label{}
\end{submybox}
\end{minipage}
\begin{minipage}[t]{.58\textwidth}
\lipsum[1]
\end{minipage}
\begin{minipage}{\textwidth}
\centering
\begin{submybox}{.3\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\end{minipage}
\end{shaded*}
\caption{\textbf{Box Test.}}
\label{box:test}
\end{mybox}
\end{document}