1

I would need a titlehead on my title page (see related question here) and, format the title page with the titling packages. Unfortunately the titlehead disappears when the titling package is loaded.

Is there any way to add a header for the title page with the titling-package?

P.S. For some reason \thetitle does not display the main title, either, but the latest (subsub)section header. These issues could be interrelated.

enter image description here

\documentclass[a4paper,12pt,bibliography=totoc]{scrartcl}

%----------------------

\usepackage{titling}
\pretitle{\huge \centering \bfseries }
\posttitle{\par \vspace{\baselineskip}} % 


\preauthor{\centering \normalsize}
\postauthor{\par}

%--------------------------------

\usepackage{titlesec} % for editing titles
% Following formats titles
\titleformat{\section}{\normalfont\fontsize{14}{12}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\fontsize{12}{12}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\normalfont\fontsize{12}{12}\itshape}{\thesubsubsection}{1em}{}



%----------------------------------
\usepackage[affil-it]{authblk} 
\usepackage{blindtext} 
\usepackage{newtxtext} % text in Times font
\usepackage{newtxmath} % math in Times font
\setkomafont{disposition}{\bfseries} % Makes sure everything, even fonts are in Times font
%\usepackage{fontspec}
%\setmainfont{Times New Roman}


\titlehead{THIS NEEDS TO BE DISPLAYED \hfill} 
\title{Main Title}
\subtitle{Sub Title}
\author[1,2,*]{First Author}
\author[1,2]{Second Author}
\author[1,3]{Third Author}
\author[2,4]{Supervisor Author}
\affil[1]{University}
\affil[2]{College}
\affil[3]{Institute}
\affil[4]{School \break}
\affil[*]{Corresponding author: [email protected] \newline Contributing authors: [email protected], [email protected], [email protected]}
\date{\today}


\begin{document}
    
    \maketitle
    
    \section{Section}
    \subsection{Subsection}
    \subsubsection{Subsubsection}
    
    Reference to the title, which is:  \thetitle % dependent on the titling-package
    
    
\end{document}

2 Answers 2

1

The titling package redefines \maketitle. Therefore it breaks the usage of KOMA-Script command \titlehead.

You can use package scrlayer or scrlayer-scrpage to add the title head:

\usepackage{scrlayer}% or scrlayer-scrpage which loads scrlayer
\DeclareNewLayer[%
  headsep,
  foreground,
  contents={%
    \begin{minipage}[t]{\textwidth}%
      \usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
    \end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}

Important remark: Do not use package titlsec together with a KOMA-Script class. It breaks KOMA-Script features. Therefore you will get a bunch of warnings and maybe errors. Additionally this package defines an own \thetitle. So it is the reason for your second issue.

Here is a suggestion replacing your titlesec settings by KOMA-Script commands:

\documentclass[a4paper,12pt,bibliography=totoc,
  numbers=noenddot,% <- added
  sfdefaults=false% <- added (replaces \setkomafont{disposition}{\bfseries}), needs version 3.39 or newer
]{scrartcl}


%----------------------

\usepackage{titling}
\pretitle{\huge \centering \bfseries }
\posttitle{\par \vspace{\baselineskip}} % 
\preauthor{\centering \normalsize}
\postauthor{\par}

\setkomafont{section}{\fontsize{14}{12}\selectfont}
\setkomafont{subsection}{\fontsize{12}{12}\selectfont}
\setkomafont{subsubsection}{\normalfont\itshape\fontsize{14}{12}\selectfont}

\renewcommand{\sectionformat}{\thesection\autodot\hspace{1em}}
\renewcommand{\subsectionformat}{\thesubsection\autodot\hspace{1em}}
\renewcommand{\subsubsectionformat}{\thesubsubsection\autodot\hspace{1em}}

\usepackage{scrlayer}% or scrlayer-scrpage which loads scrlayer
\DeclareNewLayer[%
  headsep,
  foreground,
  contents={%
    \begin{minipage}[t]{\textwidth}%
      \usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
    \end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}


%----------------------------------
\usepackage[affil-it]{authblk} 
\usepackage{blindtext} 
\usepackage{newtxtext} % text in Times font
\usepackage{newtxmath} % math in Times font
%\usepackage{fontspec}
%\setmainfont{Times New Roman}


\titlehead{THIS NEEDS TO BE DISPLAYED \hfill} 
\title{Main Title}
\subtitle{Sub Title}
\author[1,2,*]{First Author}
\author[1,2]{Second Author}
\author[1,3]{Third Author}
\author[2,4]{Supervisor Author}
\affil[1]{University}
\affil[2]{College}
\affil[3]{Institute}
\affil[4]{School \break}
\affil[*]{Corresponding author: [email protected] \newline Contributing authors: [email protected], [email protected], [email protected]}
\date{\today}


\begin{document}
\maketitle

\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Reference to the title, which is:  \thetitle. % dependent on the titling-package
\end{document}

enter image description here


Update:

If the title page should use the same footer like other pages, load package scrlayer-scrpage and add the footer layers to the new layer page style:

\usepackage{scrlayer-scrpage}% sets page style scrheadings automatically
\DeclareNewLayer[%
  headsep,
  foreground,
  contents={%
    \begin{minipage}[t]{\textwidth}%
      \usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
    \end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\ForEachLayerOfPageStyle{scrheadings}{%
  \Ifstrstart{#1}{scrheadings.foot}{\AddLayersToPageStyle{titlepage}{#1}}%
}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}

Example:

\documentclass[a4paper,12pt,bibliography=totoc,
  numbers=noenddot,% <- added
  sfdefaults=false% <- added (replaces \setkomafont{disposition}{\bfseries}), needs version 3.39 or newer
]{scrartcl}

%----------------------

\usepackage{titling}
\pretitle{\huge \centering \bfseries }
\posttitle{\par \vspace{\baselineskip}} % 
\preauthor{\centering \normalsize}
\postauthor{\par}

\setkomafont{section}{\fontsize{14}{12}\selectfont}
\setkomafont{subsection}{\fontsize{12}{12}\selectfont}
\setkomafont{subsubsection}{\normalfont\itshape\fontsize{14}{12}\selectfont}

\renewcommand{\sectionformat}{\thesection\autodot\hspace{1em}}
\renewcommand{\subsectionformat}{\thesubsection\autodot\hspace{1em}}
\renewcommand{\subsubsectionformat}{\thesubsubsection\autodot\hspace{1em}}

\usepackage{scrlayer-scrpage}% sets page style scrheadings automatically
\DeclareNewLayer[%
  headsep,
  foreground,
  contents={%
    \begin{minipage}[t]{\textwidth}%
      \usekomafont{titlehead}{\csname @titlehead\endcsname\par}%
    \end{minipage}\par}
]{titlehead}
\DeclarePageStyleByLayers{titlepage}{titlehead}
\ForEachLayerOfPageStyle{scrheadings}{%
  \Ifstrstart{#1}{scrheadings.foot}{\AddLayersToPageStyle{titlepage}{#1}}%
}
\AddToHook{cmd/maketitle/after}{\thispagestyle{titlepage}}


%----------------------------------
\usepackage[affil-it]{authblk} 
\usepackage{blindtext} 
\usepackage{newtxtext} % text in Times font
\usepackage{newtxmath} % math in Times font
%\usepackage{fontspec}
%\setmainfont{Times New Roman}


\titlehead{THIS NEEDS TO BE DISPLAYED \hfill} 
\title{Main Title}
\subtitle{Sub Title}
\author[1,2,*]{First Author}
\author[1,2]{Second Author}
\author[1,3]{Third Author}
\author[2,4]{Supervisor Author}
\affil[1]{University}
\affil[2]{College}
\affil[3]{Institute}
\affil[4]{School \break}
\affil[*]{Corresponding author: [email protected] \newline Contributing authors: [email protected], [email protected], [email protected]}
\date{\today}


\begin{document}
\maketitle

\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Reference to the title, which is:  \thetitle. % dependent on the titling-package
\end{document}

enter image description here

2
  • What if I wanted to keep page numbers on the title page? The current solution is great, but would like to have the option to include the page number - starting from 1 on the title page - for some journals. Mar 3 at 9:56
  • 1
    @SamuelSaari See the update in my answer.
    – esdd
    Mar 15 at 8:13
0

The first issue can be solved with the fancyhdr package. It would, however be better not to introduce yet another package for formatting title.

The \thetitle problem still persists.

\documentclass[a4paper,12pt,bibliography=totoc]{scrartcl}

%----------------------

\usepackage{titling}
\pretitle{\huge \centering \bfseries }
\posttitle{\par \vspace{\baselineskip}} % 


\preauthor{\centering \normalsize}
\postauthor{\par}

%--------------------------------

\usepackage{titlesec} % for editing titles
% Following formats titles
\titleformat{\section}{\normalfont\fontsize{14}{12}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\fontsize{12}{12}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\normalfont\fontsize{12}{12}\itshape}{\thesubsubsection}{1em}{}



%----------------------------------
\usepackage[affil-it]{authblk} 
\usepackage{blindtext} 
\usepackage{newtxtext} % text in Times font
\usepackage{newtxmath} % math in Times font
\setkomafont{disposition}{\bfseries} % Makes sure everything, even fonts are in Times font
%\usepackage{fontspec}
%\setmainfont{Times New Roman}


\titlehead{THIS NEEDS TO BE DISPLAYED \hfill} 
\title{Main Title}
\subtitle{Sub Title}
\author[1,2,*]{First Author}
\author[1,2]{Second Author}
\author[1,3]{Third Author}
\author[2,4]{Supervisor Author}
\affil[1]{University}
\affil[2]{College}
\affil[3]{Institute}
\affil[4]{School \break}
\affil[*]{Corresponding author: [email protected] \newline Contributing authors: [email protected], [email protected], [email protected]}
\date{\today}

%-----Added-------
\fancypagestyle{fancyfirstpage}
{
    \fancyhf{} 
    \renewcommand{\headrulewidth}{0pt}
    \pagestyle{fancy}
    \lhead{\mytitlehead}
}

%--------

\begin{document}
    
    \maketitle
    \thispagestyle{fancy} %ADDED
    
    \section{Section}
    \subsection{Subsection}
    \subsubsection{Subsubsection}
    
    Reference to the title, which is:  \thetitle % dependent on the titling-package
    
    
\end{document}

enter image description here

You must log in to answer this question.

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