Centering captions in document that contains A3 and A4 paper sizes
There is more to a page layout, then just the well known parameters like \textwidth
. For example, internally TeX uses \hsize
for building paragraphs. The best is, to leave this to the geometry
package.
Unfortunately, \newgeometry
doesn't allow to switch between portrait and landscape or change the paper size mid document. But a macro can be written, which allows this. It's basically a changed copy of \newgeometry
, called \newgeometryfull
here. Use it with care! Additionally, \pdfpageheight
and \pdfpagewidth
must be set, so the PDF viewer also knows the paper size. This is done in the a3page
environments.
I removed the line \headwidth=\textwidth
, because \headwidth
doesn't exist in your example. But may be you need it for headers not present here.
The result:
The code:
\documentclass[12pt]{article}
% Pictures & Labels
\usepackage[capitalise]{cleveref}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{textcomp}
\usepackage{float}
\usepackage[section]{placeins}
% Paper Style
\usepackage[a4paper,
width=150 mm,
top=25 mm,
bottom=25 mm]
{geometry}
\usepackage[title,toc,page]{appendix}
\usepackage{lipsum}
\makeatletter
% like \newgeometry, but also allows change of landscape/portrait and paper size
% to be used with caution!
\newcommand{\newgeometryfull}[1]{%
\clearpage
\Gm@restore@org
\Gm@initnewgm
% \Gm@newgmtrue
\setkeys{Gm}{#1}%
% \Gm@newgmfalse
\Gm@process
\ifnum\mag=\@m\else\Gm@magtooffset\fi
\Gm@changelayout
\Gm@showparams{newgeometry}}%
\makeatother
%% Allow A3 sheets - - New environment
\newenvironment{a3page}{%
\newgeometryfull{a3paper,landscape,width=360 mm,top=25 mm,bottom=25 mm}
% set the correct dimension for the PDF viewer
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
}{%
\restoregeometry
% set the correct dimension for the PDF viewer
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth
}
\begin{document}
\section{A test}
\lipsum[1]
%% Start A3 page
\begin{a3page}
\section{Title}
\lipsum[1]
\begin{figure}[H]
\centering
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:a}
\end{subfigure}%
%
%
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:b}
\end{subfigure}%
%
%
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:c}
\end{subfigure}%
%
%
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:d}
\end{subfigure}%
%
%
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:e}
\end{subfigure}%
%
%
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:f}
\end{subfigure}%
%
%
\begin{subfigure}[t]{0.14\textwidth}
\centering
\includegraphics[height=4cm]{example-image-9x16.png}
\caption{}
\label{subfig:g}
\end{subfigure}%
%
\caption{This caption isn't centered}\label{fig:}
\end{figure}
\lipsum[1]
\end{a3page}
\section{Another test}
\lipsum[1]
\end{document}