2

since I already saw that this question has already been asked here, I tried the suggested solutions but the problem still exists. I have two sub figures that are wide and I would like to place them under each other. Here is my code:

\documentclass[ngerman,12pt,a4paper,oneside,listof=totoc,plainfootsepline]{scrbook}
\addtokomafont{disposition}{\rmfamily} 
\addtokomafont{captionlabel}{\bfseries}

\RedeclareSectionCommand[beforeskip=-.5\baselineskip,afterskip=.25\baselineskip]{subsubsection} \begin{document} \begin{figure}[h] { \begin{subfigure}[h]{0.5\textwidth} \vspace{\fill} \centering \includegraphics[scale=0.5]{image1} \caption{fig1} \label{fig2}\par\vfill \end{subfigure}% \begin{subfigure}[h]{0.5\textwidth} \vspace{\fill} \centering \includegraphics[scale=0.5]{image2} \caption{fig2} \label{fig:fig2} \end{subfigure}% \caption{fig2}} \label{fig:fig2} } \end{figure} \end{document}

I tried \newline but did not work. Here is what I get on the pdf: [1]: https://i.stack.imgur.com/fzXqD.png I would be thankful for any solution.. Thanks a lot in advance..

ramles
  • 83

2 Answers2

1

From my other answer -- https://tex.stackexchange.com/a/590492/197451

enter image description here

\documentclass[12pt,a4paper,oneside,listof=totoc]{scrbook}

\usepackage[utf8]{inputenc} \usepackage[demo]{graphicx} \usepackage{caption} \usepackage{subcaption}

\RedeclareSectionCommand[beforeskip=-.5\baselineskip,afterskip=.25\baselineskip]{subsubsection} \begin{document} \begin{figure}[ht] \centering \begin{subfigure}[b]{1\textwidth} \centering \includegraphics[scale=1]{vel_ang_loop_per.eps} \caption{Componenti $p(t)$, $q(t)$ e $r(t)$ della velocità angolare.} \label{fig:p,q,r_loop_perf} \end{subfigure}\[3in]%<--------------------vary the separation

    \begin{subfigure}[b]{1\textwidth}
        \centering
        \includegraphics[scale=1]{vel_trasl_loop_per.eps}
        \caption{Componenti $u(t)$, $v(t)$, $w(t)$ della velocità del baricentro.}
        \label{fig:u,v,w_loop_perf}
    \end{subfigure}
    \caption{Storie temporali delle componenti di velocità angolare e traslazionale  assegnate per la manovra di \textit{looping perfetto}}
\end{figure}

\end{document}

js bibra
  • 21,280
0

In order to use the subfigure environment you need subcaption. For \includegraphics you need graphicx. For the ngerman option you need babel.

Next, \vspace*{\fill} and \vfill inside subfigure do nothing at all. Also, subfigure doesn't know what to do with the [h] option: it accepts [t], [b] or [c] (the last one being the default) to specify the vertical appearance of the built box; in this case you need [c] (hence you can omit it).

Using scale=0.5 is wrong: you most likely want to scale the image to the size given for subfigure. With scale you have no idea about the final size of the image, so width=\linewidth is preferable, because TeX will use the size reserved for subfigure.

You also need to fix the labels.

If you need some vertical space between the image, add it. The trick is to have a blank line between the subfigure environments (with a \vspace instruction in between).

\documentclass[
  ngerman,
  12pt,
  a4paper,
  oneside,
  listof=totoc,
  plainfootsepline,
]{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{subcaption}

\addtokomafont{disposition}{\rmfamily} \addtokomafont{captionlabel}{\bfseries}

\RedeclareSectionCommand[ beforeskip=-.5\baselineskip, afterskip=.25\baselineskip ]{subsubsection}

\begin{document}

\begin{figure}[htp] \centering

\begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\linewidth]{example-image} \caption{fig1} \label{subfig:fig1} \end{subfigure}

\vspace{3ex}

\begin{subfigure}{0.5\textwidth} \centering \includegraphics[width=\linewidth]{example-image} \caption{fig2} \label{subfig:fig2} \end{subfigure}

\caption{fig2} \label{fig:fig}

\end{figure}

\end{document}

enter image description here

If you really need scale, you can use \subcaptionbox that doesn't need a width to begin with.

\documentclass[
  ngerman,
  12pt,
  a4paper,
  oneside,
  listof=totoc,
  plainfootsepline,
]{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{subcaption}

\addtokomafont{disposition}{\rmfamily} \addtokomafont{captionlabel}{\bfseries}

\RedeclareSectionCommand[ beforeskip=-.5\baselineskip, afterskip=.25\baselineskip ]{subsubsection}

\begin{document}

\begin{figure}[htp] \centering

\subcaptionbox{fig1\label{subfig:fig1}}{% \includegraphics[scale=0.5]{example-image}% }

\vspace{3ex}

\subcaptionbox{fig2\label{subfig:fig2}}{% \includegraphics[scale=0.5]{example-image}% }

\caption{fig2} \label{fig:fig}

\end{figure}

\end{document}

The plainfootsepline option only makes sense if you load scrlayer-scrpage.

egreg
  • 1,121,712