0

I have a row of floats using the floatrow package. I'd like each on to be labeled, but the caption to be empty. When I use capposition=beside, capbesideposition={center, left}, the label is too far away from the actual float and takes up too much space.

Example:

\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}

Produces: Sample 1

When I change capbesidewidth, all that changes is the distance from the previous float:

Sample 2

  • Please extend your code fragment to complete small document which we can compile as it is. – Zarko Oct 8 '19 at 1:22
1

With using \sidesubfloat instead \floatbox I was able to obtain the following result:

enter image description here

(red lines indicate text borders)

Is this what you looking for?

\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}
  • That is what I want, but now I lose the benefit of valign=t, so if my figures are different heights (depending on arrow size) then they aren't aligned anymore. Also, thanks for the additional improvement that you made. – Otto von Bisquick Oct 8 '19 at 22:21
  • @OttovonBisquick, you can change subcapbesideposition from center to top and images will be aligned to their top. For test than in one picture add to one edge option [looseness=4] and see difference, e.g. if result is more acceptable to you. – Zarko Oct 9 '19 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.