# How to limit the text box height in the first landscape page?

I am not able to control the text box vertical size only for the first page in landscape. How can I limit the height and make the footer visible?

I am starting to work with LaTeX and had to do some adaptations to use this landscape mode because of the footers and headers (must be aligned with text, as in portrait mode). I tried \vsize, \textheight but nothing seems to work. And the most weird part is that is only on the first page, the others are okay.

I am running MiKTeX (XeLaTeX+MakeIndex+BibTeX).

Error:

My code so far:

\documentclass[a4paper]{article}

\usepackage{fancyhdr}
\usepackage{lipsum}

\usepackage{tikz}
\usepackage{layout}

\usepackage{fontspec}  % set some font
\setmainfont{Arial}

\usepackage{wallpaper}
\usepackage[left=3cm, right=2cm, bottom=4cm, top=2cm, showframe]{geometry}
%\usepackage[left=3cm, right=2cm, bottom=4cm, top=2cm]{geometry}

\lfoot{tt\\\today}
\rfoot{ff\\\thepage}

\pagestyle{fancy}

%regular portrait configurations
\newlength{\paperheightPortrait}
\setlength{\paperheightPortrait}{\paperheight}
\newlength{\paperwidthPortrait}
\setlength{\paperwidthPortrait}{\paperwidth}
\newlength{\textheightPortrait}
\setlength{\textheightPortrait}{\textheight}
\newlength{\textwidthPortrait}
\setlength{\textwidthPortrait}{\textwidth}
\newlength{\vsizePortrait}
\setlength{\vsizePortrait}{\vsize}
\newlength{\hsizePortrait}
\setlength{\hsizePortrait}{\hsize}

%landscape configurations are the opposite:
\newlength{\textheightLandscape}
\setlength{\textheightLandscape}{\textwidthPortrait}
\newlength{\textwidthLandscape}
\setlength{\textwidthLandscape}{\textheightPortrait}
\newlength{\paperheightLandscape}
\setlength{\paperheightLandscape}{\paperwidthPortrait}
\newlength{\paperwidthLandscape}
\setlength{\paperwidthLandscape}{\paperheightPortrait}
\newlength{\vsizeLandscape}
\setlength{\vsizeLandscape}{\hsizePortrait}
\newlength{\hsizeLandscape}
\setlength{\hsizeLandscape}{.674\vsizePortrait}

\fancyhf{}
\fancyfoot[L]{M\\$*''}
\fancyfoot[C]{\thepage}
\fancyfoot[R]{\today}
\renewcommand{\footrulewidth}{1pt}
\setlength{\footskip}{15pt}
\pagestyle{fancy}

\begin{document}
\ULCornerWallPaper{1}{bg_a4_portrait_logo}
\layout
measures \\
paperheightPortrait \the\paperheightPortrait \\
paperwidthPortrait  \the\paperwidthPortrait \\
textwidthPortrait   \the\textwidthPortrait \\
textheightPortrait  \the\textheightPortrait \\
vsizePortrait   \the\vsizePortrait \\
hsizePortrait   \the\hsizePortrait  \\
paperheightLandscape    \the\paperheightLandscape \\
paperwidthLandscape \the\paperwidthLandscape \\
textwidthLandscape  \the\textwidthLandscape \\
textheightLandscape \the\textheightLandscape \\
vsizeLandscape  \the\vsizeLandscape \\
hsizeLandscape  \the\hsizeLandscape  \\
\lipsum[1-10]

%landscape
\newpage %need to be here (before page settings change)
\pdfpageheight=\paperheightLandscape
\pdfpagewidth=\paperwidthLandscape
\paperwidth=\paperwidthLandscape
\paperheight=\paperheightLandscape
\newpage

\begingroup
\ClearWallPaper
\ULCornerWallPaper{1}{bg_a4_landscape_logo}

\textwidth=\textwidthLandscape
\textheight=\textheightLandscape
%\vsize=\vsizeLandscape
\hsize=\hsizeLandscape

\newpage
LANDSCAPE ----------------------------------------------------------------
\lipsum[1-22]
\endgroup
LANDSCAPE END --------------------------------------------------------------\\

%restore configs
\newpage
\pdfpageheight=\paperheightPortrait
\pdfpagewidth=\paperwidthPortrait
\paperwidth=\paperwidthPortrait
\paperheight=\paperheightPortrait
%since the variables below were changed inside the environment, we dont restore it
%\vsize=\vsizePortrait
%\hsize=\hsizePortrait
%\textwidth=\textwidthPortrait
%\textheight=\textheightPortrait

\ClearWallPaper
\ULCornerWallPaper{1}{bg_a4_portrait_logo}
\lipsum[1-15]
\newpage
\lipsum[1-10]

\end{document}

• Welcome to TeX.SX! Would it be an option for you to switch to the geometry package? It has a \newgeometry command taking care of that. – TeXnician Mar 20 '17 at 5:26
• IIRC, geometry doesn't like to change the paper size, and pdflscape doesn't rotate the headers and footers. See also tex.stackexchange.com/questions/6834/… If I were going to implement this, I would use pdflscape and write my own headers and footers using the everypage package. – John Kormylo Mar 20 '17 at 19:35

I could made it work without chaning the height!

\documentclass[a4paper]{article}
%built with XeLaTex + MakeIndex + BibTeX

\usepackage{wallpaper}
\usepackage[left=3cm, right=2cm, bottom=4cm, top=2cm, showframe]{geometry}
\usepackage{typearea}
\usepackage{fancyhdr}
\usepackage{lipsum}

\usepackage{fontspec}  % set some font
\setmainfont{Arial}

\lfoot{tt\\\today}
\rfoot{ff\\\thepage}
\pagestyle{fancy}

%regular portrait configurations
\newlength{\textheightPortrait}
\setlength{\textheightPortrait}{\textheight}
\newlength{\textwidthPortrait}
\setlength{\textwidthPortrait}{\textwidth}
%landscape configurations are the opposite:
\newlength{\textheightLandscape}
\setlength{\textheightLandscape}{\textwidthPortrait}
\newlength{\textwidthLandscape}
\setlength{\textwidthLandscape}{\textheightPortrait}

\begin{document}
%set backgriund
\ULCornerWallPaper{1}{bg_a4_portrait_logo}

\lipsum[1-10]

%landscape init -------------------------------------------------------------------
\newpage
\storeareas\normalsetting
\KOMAoption{paper}{landscape} %saved the day!
\areaset{\textwidthLandscape}{\textheightLandscape}
\recalctypearea
\newpage
%update background
\ClearWallPaper
\ULCornerWallPaper{1}{bg_a4_landscape_logo}

%finally text!
BEGIN LANDSCAPE
\lipsum[1-22]
\newpage
\lipsum[1-22]
END LANDSCAPE

%undo stuffs
\cleardoublepage
\normalsetting
\newpage
%restore background
\ClearWallPaper
\ULCornerWallPaper{1}{bg_a4_portrait_logo}
%landscape end --------------------------------------------------------------------

\lipsum[1-1]
\newpage
\lipsum[1-10]

\end{document}


I know that may not be good style, but this was the best I could implement now...