7

In order to fit multiple figures on one line, my document has A4 (portrait) and A3 (landscape) pages. To set up the A3 pages I created a new environment (a trick I adapted from another solution). Please note that I can't create a separate pdf for the A3 pages and add it in because figure references, pages, sections etc. will be constantly changing.

However, when I plot the figures on the A3 page, the main caption is placed as if it was A4. (See below) How do I center the caption relative to the A3 page?

A3 doc caption is not centered

I include the code without the text in the A4 sections:

\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}
%% Allow A3 sheets - - New environment
\newenvironment{a3page}
{\newpage
\advance\textwidth\pdfpagewidth
\headwidth = \textwidth 
\pdfpagewidth=2\pdfpagewidth}
{\newpage}

\begin{document}

%% Start A3 page
\begin{a3page}
\section{Title}
\begin{figure}[H]
\centering
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic.png}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic.png}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic.png}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
                \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic.png}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic.png}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic.png}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.05\textwidth}
                \centering
                \includegraphics[height=4cm]{images/pic2.png}
        \end{subfigure}%
        \centering
        \caption{This caption isn't centered}\label{fig:}
\end{figure}
%
%
\end{a3page}
\end{document}

2 Answers 2

5

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:

enter image description here

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}
0
0

This is my not so elegant solution. I used

\eject \pdfpagewidth=16.5in \pdfpageheight=11.7in

To make the page have different size. This solution is based on this answer. Now the caption gets centered.

A3 paper after A4

\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}
 \begin{document}
A4 paper

%% Start A3 page
\eject \pdfpagewidth=16.5in \pdfpageheight=11.7in
\section{Title}
\begin{figure}[H]
\centering
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
                \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.16\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
                \caption{}
                \label{subfig:}
        \end{subfigure}%
        %
        %
        \begin{subfigure}[t]{0.05\textwidth}
                \centering
                \includegraphics[height=1cm]{example-image-b}
        \end{subfigure}%
        \centering
        \caption{This caption isn't centered}\label{fig:}
\end{figure}

\end{document}
3
  • Hi thanks for the reply. When I said I wanted the caption centering, I meant relative to the A3 page - not the pictures. I will update the question to improve clarity. Commented May 13, 2018 at 22:33
  • 1
    Your code only changes the paper size shown by the PDF viewer. It doesn't change anything for LaTeX, which still sets a portrait a4 page.
    – Mike
    Commented May 13, 2018 at 23:56
  • @Mike yep, I notice that when I added showframe. This is issue seems to be more complicated then I thought.
    – G. Bay
    Commented May 14, 2018 at 0:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .