0
\documentclass{article}[12pt]

\usepackage{setspace}
\usepackage{lastpage}
\usepackage{rotating}
\usepackage{etoolbox}
\usepackage{lscape}
\usepackage{pdflscape}
%\usepackage{textcomp}
\usepackage[titletoc]{appendix}
\usepackage{longtable}
\usepackage{easytable}
\usepackage{array}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{fancyhdr}
%\usepackage{helvetica} % uses helvetica postscript font (download helvetica.sty)
\usepackage[includeheadfoot]{geometry}
\geometry{a4paper,hmargin={2cm,2cm},vmargin={2cm,2cm}}
\usepackage{caption}
\captionsetup{skip=0pt}
\usepackage[table]{xcolor}
\usepackage{booktabs,arydshln}

\usepackage{lipsum}

\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\fancypagestyle{mydoc}{%

\fancyhf{}
\fancyhead{}

\fancyfoot{}
\fancyfoot[C]{
    \scriptsize
    Page \thepage\ of \pageref{LastPage}
    }
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}

\fancypagestyle{lscape}{%
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}
 \fancyhf{}
\fancyhead{}

\fancyfoot{}
\fancyfoot[C]{
    \scriptsize
    Page \thepage\ of \pageref{LastPage}
    }

\fancyfoot[L]{
    \footnotesize
    Created:        14 August 2002 \\
    Modified:       20 December 2012 \\
    }
}


\begin{document}

\onehalfspacing
\title{
\vspace{48pt}
    \textbf{Application \\ \vspace{48pt}
    }   
    \vspace{96pt}
    \large{Modality: \\}
    \vspace{18pt}
    \large{Submodality: \\}
    \vspace{48pt}
    }

\author{Name \\
    \vspace{36pt}}

\maketitle
\thispagestyle{empty}
\newpage

\thispagestyle{mydoc}

\tableofcontents

\newpage
\clearpage

\pagestyle{mydoc}
\section{Section Title 1}

\lipsum[1-10]

\section{Section Title 2}

\lipsum[11-20]

\section{Appendices: Index and Supporting Evidence}

\begin{appendices}

\newgeometry{a4paper,hmargin={2cm,2cm},vmargin={-0.5cm,0cm},landscape,includeheadfoot}

\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth

\fancyhfoffset[R]{8.75cm}

\textheight=17.5cm

\makeatletter
\setlength{\@fptop}{0cm}
\makeatother

\pagestyle{lscape}

\setcounter{section}{1}
\addcontentsline{toc}{section}{\protect\numberline{\thesection}{Index}}

\begin{table}[h!]
    \normalsize
    \begin{center}
        \begin{tabular}{!{\VRule[1pt]} m{2cm} | m{4.7cm} | m{3cm} | m{4.6cm} | m{2.5cm} | m{6.2cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{6}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \textbf{\Large TEST TEXT}} & \\ [6pt]
            \specialrule{1pt}{0pt}{1pt} \specialrule{1pt}{1pt}{0pt}
            \cellcolor{gray!25}\parbox{2cm}{\centering \textbf{TEXT:}} &  & 
            \cellcolor{gray!25}\parbox{3cm}{\centering \textbf{TEXT:\\(if applicable)}} &  & 
            \cellcolor{gray!25}\parbox{2.5cm}{\centering \textbf{TEXT \\ MORE:}} &  & \\[22pt]
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
    \begin{center}
        \begin{tabular}{!{\VRule[2pt]} m{251mm} !{\VRule[2pt]} @{}m{0pt}@{} }
            \specialrule{2pt}{0pt}{0pt}
            \vspace{2pt}
            \parbox{251mm}{\centering{\LARGE{}\textbf{APPENDIX 1}}\\
            \large{}\textbf{Long text \\ Long text \\ Long text. \\ \vspace{2pt}}} & \\
            \specialrule{2pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
    \begin{center}
        \begin{tabular}{!{\VRule[1pt]} l L{22.2cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \parbox[l]{2.6cm}{\large{}\textbf{TEXT: \\ ~} }& \large{}\parbox[l]{20.5cm}{Test TEXT.} & \\[16pt]
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
        \begin{tabular}{!{\VRule[1pt]} C{2cm} !{\VRule[1pt]} L{11.8cm} !{\VRule[1pt]} L{10.5cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \textbf{\LARGE 1 - TEXT}} & \\ [20pt]
            \specialrule{1pt}{0pt}{0pt}
            \cellcolor{gray!25} ~ & \cellcolor{gray!25} \centering \large \textbf{sample} 
    & \parbox{10.3cm}{\cellcolor{gray!25} \centering \large \textbf{sample more} } & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx1 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx2 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx3 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx4 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \tiny{}} & \\
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
\end{table}

\newpage
\clearpage

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother

\begin{table}[th!]
    \begin{center}
        \begin{tabular}{!{\VRule[1pt]} l L{22.2cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \parbox[l]{2.6cm}{\large{}\textbf{TEXT: \\ ~} }& \large{}\parbox[l]{20.5cm}{Long text.} & \\[16pt]
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
        \begin{tabular}{!{\VRule[1pt]} C{2cm} !{\VRule[1pt]} L{11.8cm} !{\VRule[1pt]} L{10.5cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \textbf{\LARGE 1 - TEXT}} & \\ [20pt]
            \specialrule{1pt}{0pt}{0pt}
            \cellcolor{gray!25} ~ & \cellcolor{gray!25} \centering \large \textbf{sample} 
    & \parbox{10.3cm}{\cellcolor{gray!25} \centering \large \textbf{sample more} } & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx1 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx2 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx3 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx4 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \tiny{}} & \\
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
\end{table}


\newpage
\clearpage

\newgeometry{a4paper,hmargin={2.5cm,2.5cm},vmargin={1.5cm,2cm},includeheadfoot}

\paperwidth=\pdfpageheight
\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth

\fancyhfoffset[R]{0pt}

\section{Supporting Evidence}

\pagestyle{mydoc}

\subsection{Appendix 2}
\lipsum[1-5]

\clearpage

\subsection{Appendix 3}
\lipsum[1-5]

\end{appendices}

\end{document}
Wes
  • 13
  • Sorry, I haven't posted anything like this before, so not entirely sure how to go about it. This code should compile without any modifications (as I can't see the output pdf I was trying to attach). I have struggled quite a bit to get the landscape tables the right format; they have to remain untouched and the footer on the first landscape page is simply missing. This method of having landscape mid-document (and 2 different footers) has proven to be the best for the purpose (I have tried almost every posted solution to that problem), apart from that missing footer. Any help is much appreciated – Wes Jun 28 '17 at 14:12

1 Answers1

0

\newgeometry does not support options like a4paper and landscape (there are warnings about this in the log). So the first \newgeometry set up a portrait page, which made the \textheight much to high (and the \textwidth much to small, leading to overfull hbox warnings). You corrected this by setting it manually, but this isn't taken into account for the page on which it's set. I.e. your footer was always there, but way below the physical page.

So I came up with a new command \newgeometryswitchlc, which switches from portrait to landscape or vice versa. Since this command (like the original) restores the settings from the preamble, it can't be used to switch back. That is done with a normal \newgeometry, but you have to set \pdfpageheight and \pdfpagewidth manually after that in order to get the right dimensions in the PDF viewer.

Btw.: I commented out some packages not really needed here (and which I don't have installed).

\documentclass{article}[12pt]

\usepackage{setspace}
\usepackage{lastpage}
\usepackage{rotating}
\usepackage{etoolbox}
\usepackage{lscape}
\usepackage{pdflscape}
%\usepackage{textcomp}
%\usepackage[titletoc]{appendix}
%\usepackage{longtable}
%\usepackage{easytable}
\usepackage{array}
%\usepackage{multirow}
\usepackage{amssymb}
\usepackage{fancyhdr}
%\usepackage{helvetica} % uses helvetica postscript font (download helvetica.sty)
\usepackage[includeheadfoot]{geometry}
\geometry{a4paper,hmargin={2cm,2cm},vmargin={2cm,2cm}}
\usepackage{caption}
\captionsetup{skip=0pt}
\usepackage[table]{xcolor}
\usepackage{booktabs,arydshln}

\usepackage{lipsum}

\newcommand\VRule[1][\arrayrulewidth]{\vrule width #1}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\fancypagestyle{mydoc}{%

\fancyhf{}
\fancyhead{}

\fancyfoot{}
\fancyfoot[C]{
    \scriptsize
    Page \thepage\ of \pageref{LastPage}
    }
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}

\fancypagestyle{lscape}{%
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}
 \fancyhf{}
\fancyhead{}

\fancyfoot{}
\fancyfoot[C]{
    \scriptsize
    Page \thepage\ of \pageref{LastPage}
    }

\fancyfoot[L]{
    \footnotesize
    Created:        14 August 2002 \\
    Modified:       20 December 2012 \\
    }
}

\makeatletter
% like \newgeometry, but also switches between landscape and portait
\newcommand{\newgeometryswitchlc}[1]{%
  \clearpage
  \Gm@restore@org
  \Gm@initnewgm
  \Gm@newgmtrue
  \setkeys{Gm}{#1}%
  \Gm@newgmfalse
  % switch between landscape and portait
  \Gm@swap@papersizetrue
  \Gm@process
  % set the correct dimension for the PDF viewer
  % must be done manually when switching back with \newgeometry
  \pdfpageheight=\paperheight
  \pdfpagewidth=\paperwidth
  \ifnum\mag=\@m\else\Gm@magtooffset\fi
  \Gm@changelayout
  \Gm@showparams{newgeometry}}%
\makeatother


\begin{document}

\onehalfspacing
\title{
\vspace{48pt}
    \textbf{Application \\ \vspace{48pt}
    }   
    \vspace{96pt}
    \large{Modality: \\}
    \vspace{18pt}
    \large{Submodality: \\}
    \vspace{48pt}
    }

\author{Name \\
    \vspace{36pt}}

\maketitle
\thispagestyle{empty}
\newpage

\thispagestyle{mydoc}

\tableofcontents

\newpage
\clearpage

\pagestyle{mydoc}
\section{Section Title 1}

\lipsum[1-10]

\section{Section Title 2}

\lipsum[11-20]

\section{Appendices: Index and Supporting Evidence}

%\begin{appendices}
\appendix

% changed vmargin
\newgeometryswitchlc{hmargin={2cm,2cm},vmargin={0cm,1cm},includeheadfoot}

%\paperwidth=\pdfpageheight no longer necessary
%\paperheight=\pdfpagewidth
%\pdfpageheight=\paperheight done in \newgeometrylandscape
%\pdfpagewidth=\paperwidth

\fancyhfoffset[R]{8.75cm}

%\textheight=17.5cm to high, but

\makeatletter
\setlength{\@fptop}{0cm}
\makeatother

\pagestyle{lscape}

\setcounter{section}{1}
\addcontentsline{toc}{section}{\protect\numberline{\thesection}{Index}}

\begin{table}[h!]
    \normalsize
    \begin{center}
        \begin{tabular}{!{\VRule[1pt]} m{2cm} | m{4.7cm} | m{3cm} | m{4.6cm} | m{2.5cm} | m{6.2cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{6}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \textbf{\Large TEST TEXT}} & \\ [6pt]
            \specialrule{1pt}{0pt}{1pt} \specialrule{1pt}{1pt}{0pt}
            \cellcolor{gray!25}\parbox{2cm}{\centering \textbf{TEXT:}} &  & 
            \cellcolor{gray!25}\parbox{3cm}{\centering \textbf{TEXT:\\(if applicable)}} &  & 
            \cellcolor{gray!25}\parbox{2.5cm}{\centering \textbf{TEXT \\ MORE:}} &  & \\[22pt]
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
    \begin{center}
        \begin{tabular}{!{\VRule[2pt]} m{251mm} !{\VRule[2pt]} @{}m{0pt}@{} }
            \specialrule{2pt}{0pt}{0pt}
            \vspace{2pt}
            \parbox{251mm}{\centering{\LARGE{}\textbf{APPENDIX 1}}\\
            \large{}\textbf{Long text \\ Long text \\ Long text. \\ \vspace{2pt}}} & \\
            \specialrule{2pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
    \begin{center}
        \begin{tabular}{!{\VRule[1pt]} l L{22.2cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \parbox[l]{2.6cm}{\large{}\textbf{TEXT: \\ ~} }& \large{}\parbox[l]{20.5cm}{Test TEXT.} & \\[16pt]
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
        \begin{tabular}{!{\VRule[1pt]} C{2cm} !{\VRule[1pt]} L{11.8cm} !{\VRule[1pt]} L{10.5cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \textbf{\LARGE 1 - TEXT}} & \\ [20pt]
            \specialrule{1pt}{0pt}{0pt}
            \cellcolor{gray!25} ~ & \cellcolor{gray!25} \centering \large \textbf{sample} 
    & \parbox{10.3cm}{\cellcolor{gray!25} \centering \large \textbf{sample more} } & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx1 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx2 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx3 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx4 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \tiny{}} & \\
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
\end{table}

\newpage
\clearpage

\makeatletter
\setlength{\@fptop}{0pt}
\makeatother

\begin{table}[th!]
    \begin{center}
        \begin{tabular}{!{\VRule[1pt]} l L{22.2cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \parbox[l]{2.6cm}{\large{}\textbf{TEXT: \\ ~} }& \large{}\parbox[l]{20.5cm}{Long text.} & \\[16pt]
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
        \begin{tabular}{!{\VRule[1pt]} C{2cm} !{\VRule[1pt]} L{11.8cm} !{\VRule[1pt]} L{10.5cm} !{\VRule[1pt]} @{}m{0pt}@{} }
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \textbf{\LARGE 1 - TEXT}} & \\ [20pt]
            \specialrule{1pt}{0pt}{0pt}
            \cellcolor{gray!25} ~ & \cellcolor{gray!25} \centering \large \textbf{sample} 
    & \parbox{10.3cm}{\cellcolor{gray!25} \centering \large \textbf{sample more} } & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx1 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx2 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx3 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            Tx4 & more &   & \\ [16pt]
            \specialrule{1pt}{0pt}{0pt}
            \multicolumn{3}{ !{\VRule[1pt]} c !{\VRule[1pt]} }{\cellcolor{gray!25} \tiny{}} & \\
            \specialrule{1pt}{0pt}{0pt}
        \end{tabular}
    \end{center}
\end{table}


\newpage
\clearpage

\newgeometry{hmargin={2.5cm,2.5cm},vmargin={1.5cm,2cm},includeheadfoot}

%\paperwidth=\pdfpageheight no longer necessary
%\paperheight=\pdfpagewidth
\pdfpageheight=\paperheight
\pdfpagewidth=\paperwidth

\fancyhfoffset[R]{0pt}

\section{Supporting Evidence}

\pagestyle{mydoc}

\subsection{Appendix 2}
\lipsum[1-5]

\clearpage

\subsection{Appendix 3}
\lipsum[1-5]

%\end{appendices}

\end{document}
Mike
  • 8,664
  • Thanks Mike!!! The solution is absolutely brilliant!!!! I have no idea what the \Gm@.... commands do, but it works great!!!! Thanks again Mike!!!! – Wes Jun 29 '17 at 09:14
  • @Wes the \Gm@... commands are internal commands of geometry. They basicaly do what their name says, e.g. restoring the original geometry from the preamble (\Gm@restore@org). I just copied the definition of \newgeometry and added commands necessary to switch the page orientation. – Mike Jun 29 '17 at 20:11