I am currently writing my thesis and have to use a template which uses the kvoptions
package. My problem is, that I use a figure (consisting of two subfigures), which is automatically placed at the end of the chapter, followed by the other figures I use later on. I tried to force LaTex to place it on the following page using [p]
. Unfortunately this does not work because it is somehow interpreted as key-value-whatever.
\begin{figure}[caption={Figure}, label={fig:h2}]
\centering
\begin{subfigure}[h]{1\textwidth}
{ \includegraphics[width=1\textwidth]{figures/subfigure1.jpg}}
\caption{Subfigure}\label{fig:h2a}
\end{subfigure}
\begin{subfigure}[h]{1\textwidth}
{ \includegraphics[width=1\textwidth]{figures/subfigure2.jpg}}
\caption{Another subfigure}\label{fig:h2b}
\end{subfigure}
\end{figure}
This is the code for the figure. I know the caption and label passing is not like commonly in LaTex, buuut this is the way it is used in my template. However, changing this to the standard way and insert a positioning command like [h]
or [p]
results in the following exception:
! Package xkeyval Error: `p' undefined in families `figure'.
See the xkeyval package documentation for explanation.
Type H <return> for immediate help.
...
l.14 \begin{figure}[p]
Does someone know a way how to use the package I am forced to use and nevertheless be able to customly place figures (and tables as well I guess, cuz this works they work the same way as figures)?
Many thanks in advance!
EDIT:
I searched the template's code and found this section that redefines figure
:
\define@key{figure}{caption}{\newcommand{\figure@caption}{#1}}
\define@key{figure}{toc}{\newcommand{\figure@toc}{#1}}
\define@key{figure}{label}{\newcommand{\figure@label}{#1}}
\define@key{figure}{placement}{\newcommand{\figure@placement}{#1}}
\define@key{figure}{width}{\newcommand{\figure@width}{#1}}
\define@key{figure}{fit}[]{\newcommand{\figure@fit}{}}
\define@key{figure}{cache}{\newcommand{\figure@cache}{#1}}
\define@key{figure}{cachename}{\newcommand{\figure@cachename}{#1}}
\newcommand{\figure@private@resize@width}{}
\newcommand{\figure@private@resize@proxy}[1]{\resizebox{\figure@private@resize@width}{!}{#1}}
\renewenvironment{figure}[1][]{%
\setkeys{figure}{#1}%
\ifthenelse{\isundefined{\figure@placement}}{%
\newcommand{\figure@internal@placement}{ht}%
}{%
\ifthenelse{\equal{\figure@placement}{exact}}{%
\newcommand{\figure@internal@placement}{!ht}%{H}%
}{%
\ifthenelse{\equal{\figure@placement}{top}}{%
\newcommand{\figure@internal@placement}{t}%
}{%
\ifthenelse{\equal{\figure@placement}{bottom}}{%
\newcommand{\figure@internal@placement}{b}%
}{}%
}%
}%
}%
\expandafter\figure@default\expandafter[\figure@internal@placement]%
\ifthenelse{\isundefined{\figure@cache}}{}{%
% Control caching
\tikzset{external/export next=\figure@cache}%
% Raise a warning if a figure is not cached
% \ifthenelse{\equal{\figure@cache}{false}}{%
% \ClassWarning{isthesis}{Figure \figure@cachename is not cached.}%
% }%
}%
\ifthenelse{\isundefined{\figure@cachename}}{}{%
% Set cache name
\tikzsetnextfilename{\figure@cachename}%
}%
\center%
\ifthenelse{\isundefined{\figure@width}}{}{%
\renewcommand{\figure@private@resize@width}{\figure@width}%
\collect@body\figure@private@resize@proxy%
}%
}{%
\ifthenelse{\isundefined{\figure@toc}}{%
% Without dedicated TOC caption
\caption{\figure@caption\label{\figure@label}}%
}{%
% With dedicated TOC caption
\caption[\figure@toc]{\figure@caption\label{\figure@label}}%
}%
\endcenter%
\endfigure@default%
}
So I changed my figure:
\begin{figure}[caption={Figure}, label={fig:h2}, placement={exact}]
But this does not change anything in the outcome. In the pdf the figure is still at the end of the capter.
This is the class used by the template: https://pastebin.com/J4Vq5GpT
And this is the actual .tex file: https://pastebin.com/4VwvUDYv
The tex file uses the class as documentclass and the does all the template stuff and finally loads the content file(s).
position=htp
p
is not available but you could change it, change\newcommand{\figure@internal@placement}{ht}%
to\newcommand{\figure@internal@placement}{htp}%
to restore the default position tohtp