[Tex/LaTex] Change \textwidth and \textheight in mid-environment

geometryheader-footermarginspage-breaking

First, this is not a copy of Change \textwidth and \textheight in mid-document as I can't set a manual \pagebreak and \newgeometry or \restoregeometry thereafter.

I want to change the footer size for the first page of a document to include some kind of legend. The main content is a longtable with varying(!) content length. The legend should only be included on the first page and the footer should only be extended on this page also. This works after the lontable finishes (see lipsum text) but not while it continues. The footer stays big, although it does not contain the legend anymore.
I'm in serious doubt at the moment that it is possible with pdflatex to do what I want, but I'd like to see that I'm wrong and there is a way to do it as intended.

\documentclass[a4paper,11pt]{article}

\usepackage[top=2cm,left=2cm,right=2.5cm,bottom=5.5cm,includeheadfoot]{geometry}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage{lipsum}


% Header, Footer 
\setlength{\headheight}{26pt}
% Pagestyle firstpage
\fancypagestyle{firstpagestyle}
{
  \setlength{\textheight}{620pt}
  \setlength{\footskip}{160pt}
  \lhead{This is my header}%
  \chead{}%
  \rhead{\today}%
  \lfoot{
      \smash
    {%  % hide vertical stretch of the following content
      \parbox[b]{\textwidth}
      {
        \Legende
        This is my normal footer text.
      }
    }    
  }%
  \cfoot{}
  \rfoot{\thepage}%
  \renewcommand\headrulewidth{0.35pt}%
  \renewcommand\footrulewidth{0.35pt}%
}


% Pagestyle all other pages
\fancypagestyle{mypagestyle}
{
  \setlength{\textheight}{660.2pt}
  \setlength{\footskip}{30pt}
  \lhead{This is my header}%
  \chead{}%
  \rhead{\today}%
  \lfoot{This is my normal footer text.}
  \cfoot{}
  \rfoot{\thepage}%
  \renewcommand\headrulewidth{0.35pt}%
  \renewcommand\footrulewidth{0.35pt}%
}


\newcommand{\Legende}{
   \parbox{0.9\textwidth}{some \\ lines \\with \\ a \\ lot \\of \\text
}\\[1.5ex]}

%Dummy text for table
\newcommand{\bla}{bla \\ blubb \\ bla \\blubb \\bla \\}
\newcommand{\blubb}{\bla\bla\bla\bla\bla\bla}


\begin{document}
\pagestyle{mypagestyle}
\thispagestyle{firstpagestyle}

\renewcommand{\arraystretch}{1.25}
\begin{longtable}{c}
  \toprule
  \blubb \blubb \blubb
  \bottomrule \\[0em]
\end{longtable}

\lipsum \lipsum[1-4]

\end{document}

Best Answer

Use \enlargethispage to change the height of one page. Also don't forget that spaces can matter.

\documentclass[a4paper,11pt]{article}

\usepackage[top=2cm,left=2cm,right=2.5cm,bottom=5.5cm,includeheadfoot]{geometry}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage{lipsum}

\renewcommand\headrulewidth{0.35pt}%
\renewcommand\footrulewidth{0.35pt}%
\setlength{\headheight}{26pt}

% Header, Footer
\fancypagestyle{mypagestyle}
{\lhead{This is my header}%
  \chead{}%
  \rhead{\today}%
  \lfoot{This is my normal footer text.}
  \cfoot{}
  \rfoot{\thepage}%
 }


% Pagestyle firstpage
\fancypagestyle{firstpagestyle}
{\pagestyle{mypagestyle}
  \lfoot{%
      \smash
    {%  % hide vertical stretch of the following content
      \parbox[b]{\textwidth}
      {%
        \raggedright\Legende
        This is my normal footer text.%
      }%
    }%
  }}



\newcommand{\Legende}{%
   \parbox{0.9\textwidth}{some \\ lines \\with \\ a \\ lot \\of \\text
}\\[1.5ex]}

%Dummy text for table
\newcommand{\bla}{bla \\ blubb \\ bla \\blubb \\bla \\}
\newcommand{\blubb}{\bla\bla\bla\bla\bla\bla}


\begin{document}
\pagestyle{mypagestyle}\thispagestyle{firstpagestyle}\enlargethispage{-130pt}

\renewcommand{\arraystretch}{1.25}
\begin{longtable}{c}
  \toprule
  \blubb \blubb \blubb
  \bottomrule \\[0em]
\end{longtable}

\lipsum \lipsum[1-4]

\end{document}