0

For some reason the page number on the second page (page after titlepage) is missing. I am working with two different page styles. It is counted but not shown.

\documentclass{report}

\usepackage[utf8]{inputenc}
\usepackage[eng]{diku}
\usepackage{hyperref}

\usepackage{fancyhdr}
\usepackage{extramarks}

%\usepackage[linktoc=all]{hyperref}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{titlesec}
%\usepackage{parskip} % Space between paragraphs
\usepackage{mathtools}
%These two are for linebreak in verbatim
\usepackage{fancyvrb}
\usepackage{fvextra}
\usepackage{xcolor}
%\usepackage[margin=1.3in]{geometry}
\usepackage{listings}
\usepackage{caption}
\usepackage{verbatim}
\usepackage{stmaryrd}
\usepackage{float}

\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage{chngcntr}

\usepackage{caption}
\usepackage{subcaption}


\usepackage[normalem]{ulem}
\useunder{\uline}{\ul}{}

\usepackage[newfloat]{minted}


\usepackage{fancyvrb}
\newcommand\userinput[1]{\textbf{#1}}
\usepackage{tgcursor}

\fancyhead[R]{\thepage}
\fancyhead[L]{\textsl{\leftmark}}
\fancyfoot[C]{}% Custom footer
\renewcommand{\headrulewidth}{0pt}% Line at the header visible
\renewcommand{\footrulewidth}{0pt}% Line at the footer visible

\counterwithout{equation}{chapter}

\providecommand*{\listingautorefname}{Listing} % For autoref listings

% Redefine the plain page style
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyfoot[C]{--~\thepage~--}%
  \renewcommand{\headrulewidth}{0pt}% Line at the header invisible
  \renewcommand{\footrulewidth}{0pt}% Line at the footer visible
}

\setlength{\headheight}{22.43335pt}

\begin{document}
\renewcommand{\thelstlisting}{\thechapter.\arabic{lstlisting}}
\renewcommand{\thelisting}{\thechapter.\arabic{listing}}

\pagenumbering{roman}
\setcounter{page}{2}

{
\pagestyle{plain}
\clearpage
\maketitle
\section*{\centering Abstract}

...

\newpage

\section*{\centering Acknowledgements}

...

\newpage

\tableofcontents

\cleardoublepage
}

\pagenumbering{arabic}
\setcounter{page}{1}
\pagestyle{fancy}
\chapter{Introduction}

\end{document}

And here is the diku.sty,

%See ReadMe.tex
\ProvidesPackage{diku}[15/9/2016 - this version should work for most people]
\RequirePackage{geometry} %Requires the geometry package to change margins on the front page
\RequirePackage{wrapfig} %Requires wrapfig to put logo next to signature
\RequirePackage[utf8]{inputenc}

%%Packages for the background picture
\RequirePackage{graphicx} %Requires the graphicx package to show a logo picture
\RequirePackage{eso-pic} %Requires the eso-pic package to change the background

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%        Package description for n00b options                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\DeclareOption*{\PackageWarning{nbi}{Unknown ‘\CurrentOption’. Please choose either options: 'dan' or 'eng'}}
\DeclareOption*{%
    \PackageWarning{diku}{I think you mistyped something in the Packageoption. The options are 'dan' or 'eng'. You typed: '\CurrentOption'}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Package description for option: 'eng'(English)          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%Declare option: English frontpage (eng)
\DeclareOption{eng}{

%%New commands for filling out the front page with annoying prefilled lines
\title{PREP} %Filling a title, if forgotten
\newcommand*{\authora}[1]{\gdef\@authora{#1}}
\newcommand*{\@authora}{Name}

\newcommand*{\authorb}[1]{\gdef\@authorb{#1}}
\newcommand*{\@authorb}{Name}

\newcommand*{\emailaa}[1]{\gdef\@emaila{#1}}
\newcommand*{\@emaila}{email}

\newcommand*{\emailb}[1]{\gdef\@emailb{#1}}
\newcommand*{\@emailb}{email}

%Provide subtitle
    \newcommand*{\subtitle}[1]{\gdef\@subtitle{#1}}
    \newcommand*{\@subtitle}{Title}

%Provide title
    \newcommand*{\project}[1]{\gdef\@project{#1}}
    \newcommand*{\@project}{Masters Thesis}

%Provide supervisor(s)
    \newcommand*{\supervisor}[1]{\gdef\@supervisor{#1}}
    \newcommand*{\@supervisor}{Supervisor}

%%Commands for registration and cataloguing
%Provide an institute
    \newcommand*{\institute}[1]{\gdef\@institute{#1}}
    \newcommand*{\@institute}{Institute}

%Provide a department
    \newcommand*{\department}[1]{\gdef\@department{#1}}
    \newcommand*{\@department}{Program Language T C}

%Provide an email:
    \newcommand*{\email}[1]{\gdef\@email{#1}}
    \newcommand*{\@email}{email \& email}

%Provide handin date
    \newcommand*{\handindate}[1]{\gdef\@handindate{#1}}
    \newcommand*{\@handindate}{31.10.2022 \texttt{\handindate}}

%Provide defence date
    \newcommand*{\defencedate}[1]{\gdef\@defencedate{#1}}
    \newcommand*{\@defencedate}{28.06.2023}

%%Command for background - well, it will become a command when I'm done :-)
%Define frontpage
    \newcommand*{\frontpage}[1]{\gdef\@frontpage{#1}}
    \newcommand*{\@frontpage}{KuRedCircle}

%Define frontpage
    \newcommand*{\secondpage}[1]{\gdef\@secondpage{#1}}
    \newcommand*{\@secondpage}{KuRed}

%Command for background (only on one page)
    \newcommand*{\background}[1]{\AddToShipoutPicture*{\includegraphics[width=0.9\paperwidth, height=0.9\paperheight]{\@background{#1}}}}
    \newcommand*{\@background}{}

    \renewcommand*{\maketitle}{%Define the content of the frontpage

\begin{titlepage}
    \newgeometry{margin=1.5cm,vmargin=2cm}
%    \background{KuRedCircle}


    {\scshape\large University\par}

\vspace*{4cm}
  
    \centering
    {\Huge\scshape\@title\unskip\strut\par}
    {\LARGE \@subtitle\unskip\strut\par}
\vspace{1cm}
    %{\Large\scshape \@project\unskip\strut\par}

    {\large\@authora\unskip\strut\par}
    {\large\texttt{\@emaila}\unskip\strut\par}
    \vspace{0.5cm}
    {\large\@authorb\unskip\strut\par}
    {\large\texttt{\@emailb}\unskip\strut\par}
    
\vspace{0.5cm}
    {\large \@date\par
\vspace{0.5cm}
    Supervised by\par
    \@supervisor\unskip\strut\par}

\vfill



% \begin{wrapfigure}{r}{6.5cm}
%   \vspace{-4cm}
%     \includegraphics[width=5cm]{RkuEng}
% \end{wrapfigure}

\restoregeometry
\end{titlepage}
}
}

\ExecuteOptions{\CurrentOption}

\ProcessOptions \relax

\endinput

I want to have that the abstract page is number 1, the acknowledgement page is number 2, the table of contents is number 3, with the page number as roman and in the bottom of the page. Then the page number should use the fancy page style from the \chapter{Introduction} and reset to 1. Currently the acknowledgement is number 2, but the page number for the abstract page is simply not shown?

10
  • The example is not complete. So we cannot compile it and reproduce the issue. Please extend it to a minimal working example, starting with \documentclass and ending with \end{document}.
    – cabohah
    Commented May 24, 2023 at 11:41
  • Right, okay. Sorry, I updated latex snippet
    – wardz
    Commented May 25, 2023 at 12:42
  • The example still does not compile, e.g., it uses external files, we do not have. Please test your code in a new directory before you post it.
    – cabohah
    Commented May 25, 2023 at 12:43
  • Your code doesn't compile still, it needs \usepackage{fancyhdr}
    – JamesT
    Commented May 25, 2023 at 12:49
  • 1
    your preamble is a mess and the definition of \maketitle in your package is faulty, it shouldn't use \newgeometry and \restoregeometry. You should clean up or you will get massive problems when the document gets longer. Commented May 29, 2023 at 17:35

1 Answer 1

3
+50

UPDATED In the file diku.sty use

\renewcommand*{\maketitle}{%Define the content of the frontpage 
    \newgeometry{margin=1.5cm}% here <<<<<<<<<<
    \begin{titlepage}           

...

    \end{titlepage}
    \restoregeometry %here <<<<<<
}

(The change of geometry of the page is done outside of the titlepage environment)

\renewcommand*{\maketitle}{%Define the content of the frontpage 
    \newgeometry{margin=1.5cm}% here <<<<<<<<<<
    \begin{titlepage}               
        %    \background{KuRedCircle}               
        {\scshape\large University\par}
        
        \vspace*{4cm}
        
        \centering
        {\Huge\scshape\@title\unskip\strut\par}
        {\LARGE \@subtitle\unskip\strut\par}
        \vspace{1cm}
        %{\Large\scshape \@project\unskip\strut\par}
        
        {\large\@authora\unskip\strut\par}
        {\large\texttt{\@emaila}\unskip\strut\par}
        \vspace{0.5cm}
        {\large\@authorb\unskip\strut\par}
        {\large\texttt{\@emailb}\unskip\strut\par}
        
        \vspace{0.5cm}
        {\large \@date\par
            \vspace{0.5cm}
            Supervised by\par
            \@supervisor\unskip\strut\par}
        
        \vfill          
        
        % \begin{wrapfigure}{r}{6.5cm}
        %   \vspace{-4cm}
        %     \includegraphics[width=5cm]{RkuEng}
        % \end{wrapfigure}
        
        %
    \end{titlepage}
    \restoregeometry%here <<<<<<
}

Using this MWE with the modified diku.sty

% !TeX TS-program = pdflatex

\documentclass{report}

\usepackage[eng]{diku} % uses the modified version <<<

\usepackage{fancyhdr}

\fancypagestyle{fancy}{%
\fancyhead[R]{\thepage}
\fancyhead[L]{\textsl{\leftmark}}
\fancyfoot[C]{}% Custom footer
\renewcommand{\headrulewidth}{0pt}% Line at the header visible
\renewcommand{\footrulewidth}{0pt}% Line at the footer visible
}

% Redefine the plain page style
\fancypagestyle{plain}{%
    \fancyhf{}%
    \fancyfoot[C]{--~\thepage~--}%
    \renewcommand{\headrulewidth}{0pt}% Line at the header invisible
    \renewcommand{\footrulewidth}{0pt}% Line at the footer visible
}

\setlength{\headheight}{25pt}

%***************** for testing
\usepackage{showframe} %Only to show the margins
\usepackage{kantlipsum}% dummy text
%***************** 

\begin{document}

    \pagenumbering{roman}   
    {%
        \pagestyle{plain}
        \maketitle
        \section*{\centering Abstract}
        \kant[1]            
        \newpage
        
        \section*{\centering Acknowledgements}      
        \kant[2]
        \newpage
        
        \tableofcontents        
        \cleardoublepage
    }
    
    \pagenumbering{arabic}
    \setcounter{page}{1}
    \pagestyle{fancy}
    \chapter{Introduction}
    
    \kant[1-5]
    
\end{document}

the result is

x

y

2
  • Yep, this works. Thank you. Just curious, but why would the second page be part of the titlepage?
    – wardz
    Commented May 30, 2023 at 9:03
  • @wardz Please see the updated answer. Commented May 30, 2023 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .