1

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:

enter image description here

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}

\lhead{tt\\Foo}
\rhead{vv\\\thepage}
\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}
\newlength{\headwidthPortrait}
\setlength{\headwidthPortrait}{\headwidth}

%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}
\newlength{\headwidthLandscape} %header width
\setlength{\headwidthLandscape}{\textwidthLandscape}


\fancyhf{}
\fancyhead[L]{Top Left}
\fancyhead[C]{Top Center}
\fancyhead[R]{Top Right}
\renewcommand{\headrulewidth}{1pt}
\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  \\
headwidthPortrait   \the\headwidthPortrait \\
paperheightLandscape    \the\paperheightLandscape \\
paperwidthLandscape \the\paperwidthLandscape \\
textwidthLandscape  \the\textwidthLandscape \\
textheightLandscape \the\textheightLandscape \\
vsizeLandscape  \the\vsizeLandscape \\
hsizeLandscape  \the\hsizeLandscape  \\
headwidthLandscape  \the\headwidthLandscape \\
\lipsum[1-10]


%landscape
\newpage %need to be here (before page settings change)
\headwidth=\headwidthLandscape
\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
\headwidth=\headwidthPortrait
\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}
2
  • 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
2

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}

\lhead{tt\\Foo}
\rhead{vv\\\thepage}
\lfoot{tt\\\today}
\rfoot{ff\\\thepage}
\pagestyle{fancy}

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


\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
\setlength{\headwidth}{\headwidthLandscape}
%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
\setlength{\headwidth}{\headwidthPortrait}
\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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.