Wie erstelle ich neue Unterfloats?

Wie erstelle ich neue Unterfloats?

Mithilfe von \newfloatkönnen neue Float-Umgebungen erstellt werden, wie inDasPost, ich habe einen neuen Float namens erstellt, suppfigmöchte aber Unterfiguren hinzufügen. Wenn ich einfach Unterfiguren hinzufüge, erhalte ich die Meldung:

Kein Zähler subsuppfigdefiniert.

Wenn ich einen Zähler namens subsuppfig hinzufüge, \newcounter{subsuppfig}erhalte ich

Unzulässige Maßeinheit (pt eingefügt).

Wie definiere ich eine neue Subfloat-Umgebung?


Code:

\documentclass{article}
\usepackage{float,subcaption,graphicx}

\begin{document}

\newfloat{suppfig}{tbh}{supp}
\floatname{suppfig}{Supplementary Figure}
\begin{suppfig}[H]
  \centering
  \begin{subfigure}{\textwidth}
    \centering
    \caption{ }
    \includegraphics[width=\textwidth]{example-image-a}
  \end{subfigure}

  \begin{subfigure}{\textwidth}
    \centering
    \caption{ }
    \includegraphics[width=\textwidth]{example-image-b}
  \end{subfigure}
  \caption{...figurecaptions...}
\end{suppfig}
\end{document}

Antwort1

Verwenden Sie das Paket newfloat, ein Paket, das für die Zusammenarbeit mit captionund Freunden entwickelt wurde.

\documentclass{article}
\usepackage{newfloat}
\usepackage{subcaption}
\DeclareFloatingEnvironment[name={Supplementary Figure}]{suppfigure}
\begin{document}
\begin{suppfigure}
    \begin{subsuppfigure}{.45\textwidth}
        \centering\rule{.9\linewidth}{2cm}
    \caption{a small supplementary figure}
\end{subsuppfigure}\hfill%
    \begin{subsuppfigure}{.45\textwidth}
        \centering\rule{.9\linewidth}{2cm}
    \caption{another small supplementary figure}
\end{subsuppfigure}
\caption{And a captin for all of them}
\end{suppfigure}
\end{document}

Antwort2

subcaptionfunktioniert gut (automatisch) bei Verwendungnewfloatfür die Float-Erstellung. Wenn Sie jedochfloatoderfloatrow, Sie müssen die ganze Laufarbeit selbst erledigen.

Das Folgende ist entnommen aus demsubcaptionDokumentation(Abschnitt5 Der \DeclareCaptionSubTypeBefehl):

Um die Untertitelfunktion des captionPakets nutzen zu können, müssen einige Befehle und Zähler vorbereitet werden. Dies geschieht mit

\DeclareCaptionSubType[<numbering scheme>]{<type>}
\DeclareCaptionSubType*[<numbering scheme>]{<type>}

Für die Umgebungen figure& tableund alle mit „ \DeclareFloatingEnvironmentVom Paket angeboten newfloat“ definierten Umgebungen geschieht dies automatisch, für andere Umgebungen (z. B. die mit „ \newfloatVom floatPaket angeboten“ oder „ \DeclareNewFloatTypeVom floatrowPaket angeboten“ definierten Umgebungen) muss dies jedoch manuell erfolgen.

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{float,graphicx,subcaption}


\newfloat{suppfig}{tbh}{supp}
\floatname{suppfig}{Supplementary Figure}
\DeclareCaptionSubType{suppfig}
\renewcommand{\thesubsuppfig}{\Alph{subsuppfig}}

\begin{document}

\begin{suppfig}[H]
  \centering
  \begin{subfigure}{\textwidth}
    \centering
    \caption{First subcaption}
    \includegraphics[width=.6\linewidth]{example-image-a}
  \end{subfigure}

  \begin{subfigure}{\textwidth}
    \centering
    \caption{Second subcaption}
    \includegraphics[width=.6\linewidth]{example-image-b}
  \end{subfigure}
  \caption{Figure caption}
\end{suppfig}

\end{document}

verwandte Informationen