From ad1928316d819ffb337fc4a926dbef47607dfb95 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sun, 1 Mar 2020 03:01:38 +0000
Subject: CTAN sync 202003010301

---
 macros/latex/contrib/autofancyhdr/autofancyhdr.sty | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 macros/latex/contrib/autofancyhdr/autofancyhdr.sty

(limited to 'macros/latex/contrib/autofancyhdr/autofancyhdr.sty')

diff --git a/macros/latex/contrib/autofancyhdr/autofancyhdr.sty b/macros/latex/contrib/autofancyhdr/autofancyhdr.sty
new file mode 100644
index 0000000000..83613a59b4
--- /dev/null
+++ b/macros/latex/contrib/autofancyhdr/autofancyhdr.sty
@@ -0,0 +1,69 @@
+\ProvidesPackage{autofancyhdr}%
+           [2019/01/18 v0.1
+                  Extensive control of page headers and footers with automatic calculate headheight]%
+\RequirePackage{fancyhdr}
+\RequirePackage{biditools}
+\def\headfootlength{}
+% Redefine \f@nch@vbox for auto height
+\def\f@nch@vbox#1#2{%
+	\setbox0\vbox{#2}%
+	\ifdim\ht0=#1\else%
+	\f@nch@warning{%
+		\string#1 (\the#1) is not equal with \the\ht0.^^J
+		Please compile again to correct this problem.%
+	}%
+	\fi%
+	\ifx#1\headheight%
+	\edef\eheadfootlength{%
+		\string\expandafter\string\def\string\csname\space
+		headleng\thepage \string\endcsname{\strip@pt\ht0}%
+	}%
+	\expandafter\g@addto@macro\expandafter\headfootlength\expandafter{%
+		\eheadfootlength^^J%
+	}%
+	\fi%
+	\box0%
+}
+\bidi@AfterOutputPageShipOut{%
+	\newdimen\newheadheight%
+	\ifcsname headleng\the\numexpr\value{page}+1\relax\endcsname%
+	\setlength{\newheadheight}{%
+		\csname headleng\the\numexpr\value{page}+1\relax\endcsname pt%
+	}%
+	\else%
+	\ifcsname headleng1\endcsname%
+	\setlength{\newheadheight}{%
+		\csname headleng1\endcsname pt%
+	}%
+	\else%
+		\setlength{\newheadheight}{0pt}%
+	\fi%
+	\fi%
+	\global\setlength{\textheight}{
+		\dimexpr\textheight+\headheight-\newheadheight\relax
+	}%
+	\global\setlength{\headheight}{\newheadheight}%
+}%
+\IfFileExists{\jobname.headfootlength}
+{
+	\input{\jobname.headfootlength}
+}
+{}
+\ifcsname headleng1\endcsname
+\global\setlength\headheight{\csname headleng1\endcsname pt}
+\else
+\global\setlength\headheight{0pt}
+\fi
+\bidi@AfterLastShipout{%
+	\if@filesw%
+	\begingroup
+	% same write register as environment `filecontents` uses
+	\chardef\reserved@c=15 %
+	\immediate\openout\reserved@c=\jobname.headfootlength\relax
+	\immediate\write\reserved@c{%
+		\headfootlength%
+	}%
+	\immediate\closeout\reserved@c
+	\endgroup
+	\fi%
+}
\ No newline at end of file
-- 
cgit v1.2.3

