tikzpicture によるキャプションの配置ミス

tikzpicture によるキャプションの配置ミス

tikzpicture を使用するときにサブキャプションの配置に問題があります\subfloat

これが私の MWE です:

\documentclass[a4paper,
               11pt,
               ngerman]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{caption}

\setkomafont{captionlabel}{\small\bfseries}
\setkomafont{caption}{\small}
\setcapindent{0em}
\setcapwidth{0.9\textwidth}
\captionsetup[subfigure]{font={footnotesize},labelfont={bf,footnotesize}}

\usepackage{tikz}
\usetikzlibrary{trees}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows}

\begin{document}

\tikzset{
    momentum/.style={postaction={decorate},
decoration={markings, mark=at position 1 with {\arrow[scale=0.8]{>}}}},
}

\begin{figure}[tb]
\subfloat[Winkel zwischen 1 und 3 am kleinsten]{
  \centering
  \begin{tikzpicture}[font=\small,scale=0.3]
    \centering
      \draw[momentum](5,5)--(5,1);
      \node[anchor=north]at(5,1){2};
      \draw[momentum](5,5)--(4,9);
      \node[anchor=east]at(4,9){1};
      \draw[momentum](5,5)--(6,9);
      \node[anchor=west]at(6,9){3};
  \end{tikzpicture}
} \hspace{1cm}
\subfloat[Winkel zwischen 2 und 3 am kleinsten]{
  \centering
  \begin{tikzpicture}[font=\small,scale=0.3]
    \centering
      \draw[momentum](5,5)--(5,1);
      \node[anchor=north]at(5,1){1};
      \draw[momentum](5,5)--(4,9);
      \node[anchor=east]at(4,9){2};
      \draw[momentum](5,5)--(6,9);
      \node[anchor=west]at(6,9){3};
  \end{tikzpicture}
} \hspace{1cm}
\subfloat[Alle Winkel etwa gleich groß]{
  \centering
  \begin{tikzpicture}[font=\small,scale=0.3]
    \centering
      \draw[momentum](5,5)--(5,1);
      \node[anchor=north]at(5,1){1};
      \draw[momentum](5,5)--(1,8);
      \node[anchor=east]at(1,8){2};
      \draw[momentum](5,5)--(9,8);
      \node[anchor=west]at(9,8){3};
  \end{tikzpicture} }
\caption{Bildunterschrift}
\end{figure}

\end{document}

コンパイルは成功しましたが、設定したサブキャプションの位置\subfloat[...]が間違っています。

mweの出力

この時点では、beamer クラスでまったく同じコードを使用すると完全に正常に動作するため、完全に混乱しています。

subfigureパッケージやの使用は避けたいですsubcaption。どこかで、サブフロートをミニページでラップするとよいかもしれないと読んだのですが、うまくいきませんでした。

これについて何かアイデアはありますか?

編集 @Troy と @John_Kormylo のヒントを使用して、自分にとって有効な解決策を見つけました。コメントアウトして\setcapwidth{0.9\textwidth}、tikzpicture を使用するものを除くすべての図と表に追加しました...\setcapwidth{\textwidth}問題のあるサブフロートを内部に追加しても何も変わりませんでした。

答え1

KOMA クラスは と互換性がありませんsubfig。代わりに を使用できますsubcaption

\documentclass[
  a4paper,
  11pt,
  ngerman
]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{caption,subcaption}

\setkomafont{captionlabel}{\small\bfseries}
\setkomafont{caption}{\small}
\setcapindent{0em}
\setcapwidth{0.9\textwidth}
\captionsetup[subfigure]{font={footnotesize},labelfont={bf,footnotesize}}

\usepackage{tikz}
\usetikzlibrary{trees}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows}

\tikzset{
  momentum/.style={
    postaction={decorate},
    decoration={
      markings,
      mark=at position 1 with {\arrow[scale=0.8]{>}},
    },
  },
}

\begin{document}

\begin{figure}[tb]

\begin{subfigure}[b]{.3\textwidth}
\centering
\begin{tikzpicture}[font=\small,scale=0.3]
  \draw[momentum](5,5)--(5,1);
  \node[anchor=north]at(5,1){2};
  \draw[momentum](5,5)--(4,9);
  \node[anchor=east]at(4,9){1};
  \draw[momentum](5,5)--(6,9);
  \node[anchor=west]at(6,9){3};
\end{tikzpicture}
\caption{Winkel zwischen 1 und 3 am kleinsten}
\end{subfigure}\hfill
\begin{subfigure}[b]{.3\textwidth}
\centering
\begin{tikzpicture}[font=\small,scale=0.3]
  \draw[momentum](5,5)--(5,1);
  \node[anchor=north]at(5,1){1};
  \draw[momentum](5,5)--(4,9);
  \node[anchor=east]at(4,9){2};
  \draw[momentum](5,5)--(6,9);
  \node[anchor=west]at(6,9){3};
\end{tikzpicture}
\caption{Winkel zwischen 2 und 3 am kleinsten}
\end{subfigure}\hfill
\begin{subfigure}[b]{.3\textwidth}
\centering
\begin{tikzpicture}[font=\small,scale=0.3]
  \draw[momentum](5,5)--(5,1);
  \node[anchor=north]at(5,1){1};
  \draw[momentum](5,5)--(1,8);
  \node[anchor=east]at(1,8){2};
  \draw[momentum](5,5)--(9,8);
  \node[anchor=west]at(9,8){3};
\end{tikzpicture}
\caption{Alle Winkel etwa gleich groß}
\end{subfigure}

\caption{Bildunterschrift}
\end{figure}

\end{document}

ここに画像の説明を入力してください

答え2

\setcapdynwidthKOMA-Script バージョン 3.20 以降では、代わりにを使用できます\setcapwidth。KOMA-Script のドキュメントから:

は、 と同様に、パラメータ width の値を直ちに\setcapwidth設定することに注意してください。 代わりに、キャプションが設定されたときにの値が必要な場合は、 を使用できます。 たとえば、長さなどを使用したり、他のコマンドを引数として使用したりすると、結果が異なる場合があります。width\setlengthwidth\setcapdynwidth\linewidthwidth

\documentclass[a4paper,
               11pt,
               ngerman]{scrreprt}[2016/05/10]
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{caption}

\setkomafont{captionlabel}{\small\bfseries}
\setkomafont{caption}{\small}
\setcapindent{0em}
\setcapdynwidth{0.9\textwidth}% <- changed, needs KOMA-Script version 3.20
\captionsetup[subfigure]{font={footnotesize},labelfont={bf,footnotesize}}

\usepackage{tikz}
\usetikzlibrary{trees}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows}

\begin{document}

\tikzset{
    momentum/.style={postaction={decorate},
decoration={markings, mark=at position 1 with {\arrow[scale=0.8]{>}}}},
}

\begin{figure}[tb]
\subfloat[Winkel zwischen 1 und 3 am kleinsten]{
  \centering
  \begin{tikzpicture}[font=\small,scale=0.3]
    \centering
      \draw[momentum](5,5)--(5,1);
      \node[anchor=north]at(5,1){2};
      \draw[momentum](5,5)--(4,9);
      \node[anchor=east]at(4,9){1};
      \draw[momentum](5,5)--(6,9);
      \node[anchor=west]at(6,9){3};
  \end{tikzpicture}
} \hspace{1cm}
\subfloat[Winkel zwischen 2 und 3 am kleinsten]{
  \centering
  \begin{tikzpicture}[font=\small,scale=0.3]
    \centering
      \draw[momentum](5,5)--(5,1);
      \node[anchor=north]at(5,1){1};
      \draw[momentum](5,5)--(4,9);
      \node[anchor=east]at(4,9){2};
      \draw[momentum](5,5)--(6,9);
      \node[anchor=west]at(6,9){3};
  \end{tikzpicture}
} \hspace{1cm}
\subfloat[Alle Winkel etwa gleich groß]{
  \centering
  \begin{tikzpicture}[font=\small,scale=0.3]
    \centering
      \draw[momentum](5,5)--(5,1);
      \node[anchor=north]at(5,1){1};
      \draw[momentum](5,5)--(1,8);
      \node[anchor=east]at(1,8){2};
      \draw[momentum](5,5)--(9,8);
      \node[anchor=west]at(9,8){3};
  \end{tikzpicture} }
\caption{Bildunterschrift}
\end{figure}

\end{document}

結果:

ここに画像の説明を入力してください

関連情報