1

I'm new to LaTeX and am trying to create a subtitle for a document. I'm using the titling package because it propagates values like the document title, author name, etc. even after maketitle is called. I want to use the subtitle as part of the header I've defined using the fancyhdr package. While I've been able to create and format the subtitle as I like I cannot figure out how to make its value available for use later in the document. Here is a minimal working example of what I have been able to build so far:

\documentclass{article}

\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{lipsum}

%define subtitle command
\newcommand{\subtitle}[1]{%
    \posttitle{%
        \par\end{center}
        \begin{center}\Large#1\end{center}
        \vskip0.5em%
    }
}

\title{Paper Title}
\subtitle{Paper Sub-title}
\author{Author Name}
\date{\today}

\pagestyle{fancy}
\rhead{\theauthor}
\lhead{\thetitle} % I want to replace this with the subtitle defined above

\begin{document}
\maketitle
\lipsum
\end{document}

I've tried exporting the subtitle value by adding \def \thesubtitle#1% in the new subtitle command and then using\lhead{\thesubtitle} in the preamble to generate the header I want but I get no output from it. I'm sure I'm missing something simple and would appreciate any help.

  • Like this: \newcommand{\subtitle}[1]{% \newcommand\thesubtitle{#1}% \posttitle{% \par\end{center} \begin{center}\Large#1\end{center} \vskip0.5em% }}? – jon Jan 22 '18 at 6:17
  • @jon Would you like to add an answer? – CarLaTeX Jan 22 '18 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.