0

I have recently added the fancyhdr package (v4.0.3, i.e. latest version) to my application code and it works on Windows 10 with MiKTeX (current version). My application always worked also on Ubuntu 20.04 LTS with TeX Live. So I was quite surprised to discover the following error (on Ubuntu):

enter image description here

It seems to be complaining that the fancyhdr page style definitions are in the document preamble(!!!)... but MiKTeX has no issue with this at all. Isn't this where they are supposed to be?

As a test I moved them after \begin{document} but this did not solve the problem as it didn't like the square brackets in the \fancypagestyle{plain}[frontpage]{...} command (though it did get rid of the ! LaTeX Error: Missing \begin{document}. error).

After reading this: fancyhdr package not working in particular point 4.5 in the answer Few things to know first, I began to wonder if this is the same BUG? Or is it possible to fix this in the LaTeX code?

My TeX example is long, however I think the following will work as an MWE to demonstrate my issue:

\documentclass[10pt, a4paper]{report}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage{enumitem} % used to customize the {description} environment
\usepackage[nomarginpar, top=21mm, bottom=15mm, left=10mm, right=10mm]{geometry}
%------------ page styles ------------
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{frontpage}{
  \fancyhf{}% clear all header and footer fields
}
\fancypagestyle{plain}[frontpage]{
  \fancyfootoffset[R]{0pt}% recalculate \headwidth
  \cfoot{\centerline{Page \thepage}}
}
\fancypagestyle{datapage}[plain]{
  \newgeometry{nomarginpar, top=21mm, bottom=18mm, left=16mm, right=16mm, headsep=2.6pt, footskip=15pt}
  \rfoot{\textsf{\footnotesize{https://pypi.org/project/pyalmanac/}}}
} %-----------------------------------
\usepackage{xcolor}  % highlight double moon events on same day
\definecolor{khaki}{rgb}{0.76, 0.69, 0.57}
\usepackage{multirow}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\usepackage[pdftex]{graphicx}   % for \includegraphics
\usepackage{tikz}               % for \draw  (load after 'graphicx')
\setlength\fboxsep{1.5pt}       % ONLY used by \colorbox in alma_ephem.py
\begin{document}
\pagestyle{frontpage}
    \begin{titlepage}
bla bla bla
\end{titlepage}
\pagestyle{datapage}  % the default page style for the document
% ------------------ N E W   P A G E ------------------
\newpage
\sffamily
\noindent
\begin{flushright}
\textbf{2022 August 14 to Aug. 15}%
\end{flushright}\par
\begin{scriptsize}
bla bla bla
\end{scriptsize}
\end{document}

I look forward to hearing your responses. By the way - I do need to change page geometry in my case - and as I mentioned this works just fine with MiKTeX.

UPDATE 15-AUG-2022:

Thanks for the first two (very helpful) comments. I have tried a few times de-installing and re-installing TeX Live on Ubuntu 20.04 LTS (Focal Fossa) and every time it installs TeX Live 2019 again. (I actually assumed that's the latest version!) Even here I only see the 2019 versions listed: https://packages.ubuntu.com/search?suite=focal&keywords=texlive

I follow the instructions that are available on most web pages:

$ sudo apt remove texlive-latex-extra
$ sudo apt autoclean && sudo apt autoremove

and afterwards:

$ sudo apt update
$ sudo apt-get install texlive-latex-extra
$ tex --versiom

I don't know if later TeX Live versions are even compatible with Focal Fossa. Does one have to install from source code? (REALLY???) Can I follow this guideline?: https://fahim-sikder.github.io/post/installing-texlive-latest-ubuntu/

2
  • 2
    works fine in a texlive 2022, but if you really installed a new fancyhdr it means that you are mixing a new fancyhdr into a texlive 2019, and that is difficult to test. Aug 14, 2022 at 21:35
  • 1
    texlive has 4.0.1 not 4.0.3 but that works in 2020, 2021 and 2022. Make a more minimal example (do you really need tikz and graphicx to show this error?) and then show the log (not terminal output) from the example. The missing document error is because it is typesetting [f as text. You have a version not accepting an optional argument in that position. Aug 14, 2022 at 21:42

0

You must log in to answer this question.

Browse other questions tagged .