I am trying to cope with a long-known bug in Koma-script (see: https://tex.stackexchange.com/questions ... r-subfloat, which is from 2013.) Before I start introducing my problem, let me give you the question I have (as I certainly would not recognise the question at the end of this...)
How can I solve the numbering issue in the non-floating environment?
When I want to number and reference subfigures correctly, a bug in Koma-script makes this impossible without a work-around. To test this try:
Code: Select all
\documentclass[paper=A4]{scrbook}
\usepackage{scrhack}
\usepackage[ngerman]{babel} %Sprachpaket
\usepackage[T1]{fontenc} %Sonderzeichen, Umlaute
\usepackage[latin9]{inputenc} %Sonderzeichen, Umlaute
\usepackage[tableposition=top,figureposition=top]{caption}
\DeclareCaptionFont{nicered}{\color{nicered}}
\captionsetup{labelfont={nicered,bf},textfont={nicered,bf}}
\usepackage{subcaption}
\renewcommand\thesubfigure{\alph{subfigure})}
\DeclareCaptionLabelFormat{opening}{(#2}
\captionsetup[subfigure]{labelformat=opening}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,calc,shapes,patterns,decorations,positioning,shadows,intersections,3d,decorations.pathreplacing} %TIKZ-Options
\usepackage{calc}
\usepackage{fp}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{txfonts}
\usepackage{soul}
\usepackage{url}
\definecolor{nicered}{rgb}{.647,.129,.149}
\begin{document}
\begin{figure}[htb!]
\centering
\caption{Fig 1}
\label{fig:1}
\begin{subfigure}{5.5cm}
\caption{Fig 1.1}
\label{fig:1:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 1.2}
\label{fig:1:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{figure}
\begin{figure}[htb!]
\centering
\caption{Fig 2}
\label{fig:2}
\begin{subfigure}{5.5cm}
\caption{Fig 2.1}
\label{fig:2:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 2.2}
\label{fig:2:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{figure}
Verweise zu den Abbildungen:
\ref{fig:1}
\ref{fig:1:1}
\ref{fig:1:2}
\ref{fig:2}
\ref{fig:2:1}
\ref{fig:2:2}
\end{document}
Code: Select all
\begin{figure}[htb!]
\centering
\captionabove{Fig 1}
\label{fig:1}
\begin{subfigure}{5.5cm}
\caption{Fig 1.1}
\label{fig:1:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 1.2}
\label{fig:1:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{figure}
\begin{figure}[htb!]
\centering
\captionabove{Fig 2}
\label{fig:2}
\begin{subfigure}{5.5cm}
\caption{Fig 2.1}
\label{fig:2:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 2.2}
\label{fig:2:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{figure}
Code: Select all
\caption
Code: Select all
\captionabove
The problem arises, when I want to put the subfigures in a non-floating environment and thereby use
Code: Select all
\captionof
Code: Select all
\captionabove
Code: Select all
\captionabove
Code: Select all
\documentclass[paper=A4]{scrbook}
\usepackage{scrhack}
\usepackage[ngerman]{babel} %Sprachpaket
\usepackage[T1]{fontenc} %Sonderzeichen, Umlaute
\usepackage[latin9]{inputenc} %Sonderzeichen, Umlaute
\usepackage[tableposition=top,figureposition=top]{caption}
\DeclareCaptionFont{nicered}{\color{nicered}}
\captionsetup{labelfont={nicered,bf},textfont={nicered,bf}}
\usepackage{subcaption}
\renewcommand\thesubfigure{\alph{subfigure})}
\DeclareCaptionLabelFormat{opening}{(#2}
\captionsetup[subfigure]{labelformat=opening}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,calc,shapes,patterns,decorations,positioning,shadows,intersections,3d,decorations.pathreplacing} %TIKZ-Options
\usepackage[framemethod=tikz]{mdframed}
\usepackage{calc}
\usepackage{fp}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{txfonts}
\usepackage{soul}
\usepackage{url}
\newcounter{Beispiel}[section]
\newenvironment{Beispiel}[1][]{%
\refstepcounter{Beispiel}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[line width=1pt,anchor=east,rectangle,draw=nicered,fill=redtitleback,general shadow={shadow scale=1, shadow xshift=0.8ex, shadow yshift=-0.8ex,
opacity=1, fill=gray!50}]
{\strut \color{nicered}{Beispiel}~\theBeispiel};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[line width=1pt,anchor=east,rectangle,draw=nicered,fill=redtitleback, general shadow={shadow scale=1, shadow xshift=0.8ex, shadow yshift=-0.8ex,
opacity=1, fill=gray!50}]
{\strut \color{nicered}{Beispiel}~\theBeispiel:~\color{nicered}{#1}};}}%
}%
\mdfsetup{roundcorner=10pt,innertopmargin=10pt,linecolor=nicered,%
linewidth=1pt,topline=true,shadow=true,%
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\DeclareCaptionType[fileext=ext]{float}
\definecolor{nicered}{rgb}{.647,.129,.149}
\definecolor{redtitleback}{cmyk}{0,0.1,0.1,0}
\begin{document}
\begin{figure}[htb!]
\centering
\captionabove{Fig 1}
\label{fig:1}
\begin{subfigure}{5.5cm}
\caption{Fig 1.1}
\label{fig:1:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 1.2}
\label{fig:1:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{figure}
\begin{figure}[htb!]
\centering
\captionabove{Fig 2}
\label{fig:2}
\begin{subfigure}{5.5cm}
\caption{Fig 2.1}
\label{fig:2:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 2.2}
\label{fig:2:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{figure}
Verweise zu den Abbildungen:
\ref{fig:1}
\ref{fig:1:1}
\ref{fig:1:2}
\ref{fig:2}
\ref{fig:2:1}
\ref{fig:2:2}
\newpage
\begin{Beispiel}[Test 1]
\label{bsp:1}
\captionof{figure}{Fig 3}
\label{fig:3}
\begin{subfigure}{5.5cm}
\caption{Fig 3.1}
\label{fig:3:1}
\includegraphics[width=4cm]{name}
\end{subfigure}
\begin{subfigure}{5.5cm}
\caption{Fig 3.2}
\label{fig:3:2}
\includegraphics[width=4cm]{name}
\end{subfigure}
\end{Beispiel}
Verweise zu den Abbildungen:
\ref{fig:3}
\ref{fig:3:1}
\ref{fig:3:2}
\end{document}
If you have any hint where to start...
Thanks. H.