Estou tendo problemas com a colocação de sublegendas \subfloat
ao usar o tikzpicture.
Aqui está meu 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}
Ele compila, mas as sublegendas que defini \subfloat[...]
estão mal posicionadas:
Estou completamente perdido neste ponto, já que usar exatamente o mesmo código na classe beamer funciona perfeitamente bem.
Quero evitar usar os pacotes subfigure
ou subcaption
. Li em algum lugar que poderia ser uma boa ideia agrupar os subflutuantes em minipáginas, mas não funcionou.
Alguma idéia sobre isso?
editar
Encontrei uma solução que funciona para mim usando as dicas de @Troy e @John_Kormylo. Comentei \setcapwidth{0.9\textwidth}
e adicionei a todas as figuras e tabelas, exceto aquelas onde uso o tikzpicture... Colocar \setcapwidth{\textwidth}
dentro dos subfloats problemáticos não mudou nada.
Responder1
As classes KOMA não são realmente compatíveis com subfig
. Você pode usar subcaption
em seu lugar.
\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}
Responder2
\setcapdynwidth
Desde a versão 3.20 do KOMA-Script você pode usar \setcapwidth
. Da documentação do KOMA-Script:
Observe que
\setcapwidth
definewidth
imediatamente o valor da largura do parâmetro, como\setlength
faria. Se você quiser o valor dewidth
quando a legenda é definida, poderá usar\setcapdynwidth
. Pode haver diferenças no resultado, se você, por exemplo, usar comprimentos como\linewidth
ou outros comandos como argumentowidth
.
\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}
Resultado: