我有一排使用该floatrow
包的浮动元素。我希望每个浮动元素都带有标签,但标题为空。当我使用时capposition=beside, capbesideposition={center, left}
,标签距离实际浮动元素太远,占用了太多空间。
例子:
\tikzset{
sort node/.style = {
rectangle,
draw = black,
anchor = north west
},
curs node/.style = {
sort node,
text = white,
fill = black
},
comp node/.style = {
sort node,
fill = gray
}
}
\begin{figure}[ht]
\floatsetup{valign=t, heightadjust=object, capposition=beside, capbesideposition={center, left}}
\begin{subfloatrow}[3]
\centering
\floatbox{figure}{\caption{}}{
\tikzsetnextfilename{Chapter02-insertion-sort-01}
\scalebox{1.5}{
\begin{tikzpicture}
\node at (0,0) [comp node, label={\tiny 1}] (a) {5};
\node at (a.north east) [curs node, label={\tiny 2}] (b) {2};
\node at (b.north east) [sort node, label={\tiny 3}] (c) {4};
\node at (c.north east) [sort node, label={\tiny 4}] (d) {6};
\node at (d.north east) [sort node, label={\tiny 5}] (e) {1};
\node at (e.north east) [sort node, label={\tiny 6}] (f) {3};
\draw [-{Stealth[length=1mm]}, gray] (a.290) to[out=270, in=270, looseness=2] (b.250);
\draw [-{Stealth[length=1mm]}] (b.300) to[out=270, in=270, looseness=2] (a.240);
\end{tikzpicture}
}
}
\floatbox{figure}{\caption{}}{
\tikzsetnextfilename{Chapter02-insertion-sort-02}
\scalebox{1.5}{
\begin{tikzpicture}
\node at (0,0) [comp node, label={\tiny 1}] (a) {2};
\node at (a.north east) [comp node, label={\tiny 2}] (b) {5};
\node at (b.north east) [curs node, label={\tiny 3}] (c) {4};
\node at (c.north east) [sort node, label={\tiny 4}] (d) {6};
\node at (d.north east) [sort node, label={\tiny 5}] (e) {1};
\node at (e.north east) [sort node, label={\tiny 6}] (f) {3};
\draw [-{Stealth[length=1mm]}, gray] (b.290) to[out=270, in=270, looseness=2] (c.250);
\draw [-{Stealth[length=1mm]}] (c.300) to[out=270, in=270, looseness=2] (b.240);
\end{tikzpicture}
}
}
\floatbox{figure}{\caption{}}{
\tikzsetnextfilename{Chapter02-insertion-sort-03}
\scalebox{1.5}{
\begin{tikzpicture}
\node at (0,0) [sort node, label={\tiny 1}] (a) {2};
\node at (a.north east) [sort node, label={\tiny 2}] (b) {4};
\node at (b.north east) [comp node, label={\tiny 3}] (c) {5};
\node at (c.north east) [curs node, label={\tiny 4}] (d) {6};
\node at (d.north east) [sort node, label={\tiny 5}] (e) {1};
\node at (e.north east) [sort node, label={\tiny 6}] (f) {3};
\draw [-{Stealth[length=1mm]}] (d.300) to[out=270, in=270, looseness=4] (d.240);
\end{tikzpicture}
}
}
\end{subfloatrow}
\end{figure}
当我改变时capbesidewidth
,唯一改变的是与前一个浮点数的距离:
答案1
通过使用\sidesubfloat
,\floatbox
我能够获得以下结果:
(红线表示文本边框)
这就是你要找的吗?
\documentclass{article}
\usepackage{geometry}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage[label font=bf, labelformat=parens]{subfig}
\usepackage{caption}
\floatsetup[figure]{style=plain, subcapbesideposition=center}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{figure}[ht]
\tikzset{
node distance = 0pt,
box/.style args = {#1/#2}{draw=gray!80, fill=#1, text=#2,
minimum width=1em, minimum height=4ex,
inner sep=2mm, outer sep=0mm,
on chain},
every edge/.style = {draw, -{Stealth[length=1mm]}, out=270, in=270, looseness=2.4},
every label/.style = {font=\tiny}
}
\sidesubfloat[\label{fig:a}]{%\tikzsetnextfilename{Chapter02-insertion-sort-01}
\begin{tikzpicture}[start chain = A going right]
\node[box=black/white, label=1] {5}; % A-1: node name
\node[box=gray/black, label=2] {2};
\node[box=white/black, label=3] {4};
\node[box=white/black, label=4] {6};
\node[box=white/black, label=5] {1};
\node[box=white/black, label=6] {3}; % A-6
%
\path (A-1.280) edge (A-2.260)
(A-2.290) edge (A-1.250);
\end{tikzpicture}
}
\hfill
\sidesubfloat[\label{fig:a}]{%\tikzsetnextfilename{Chapter02-insertion-sort-02}
\begin{tikzpicture}[start chain = B going right]
\node[box=gray/black, label=1] {2}; % B-1: node name
\node[box=gray/black, label=2] {5};
\node[box=white/black, label=3] {4};
\node[box=black/white, label=4] {6};
\node[box=black/white, label=5] {1};
\node[box=black/white, label=6] {3}; % B-6
%
\path (B-2.280) edge (B-3.260)
(B-3.290) edge (B-2.250);
\end{tikzpicture}
}
\hfill
\sidesubfloat[\label{fig:a}]{%\tikzsetnextfilename{Chapter02-insertion-sort-03}
\begin{tikzpicture}[start chain = C going right]
\node[box=black/white, label=1] {5}; % C-1: node name
\node[box=black/white, label=2] {4};
\node[box=gray/black, label=3] {5};
\node[box=white/black, label=4] {6};
\node[box=black/white, label=5] {1};
\node[box=black/white, label=6] {3}; % C-6
%
\path (C-4.290) edge (C-3.250);
\end{tikzpicture}
}
\end{figure}
\end{document}