Skip to content

(In)Compatibility with titling package regarding \thetitle #94

Description

@Lichtschalter-5000

I discovered a compatibility problem (probably related to #83 - the package hyperref is not involved with this though, could be an enhancement: #82) with the titling package. It will provide a \thetitle command which is meant to be the main document title (set with \title and displayed with \maketitle).
If I understood correctly, this package provides \thetitle as well, and redefines it at every call to \section and the like and prints the index of the current section (subsection, chapter etc.)? So I cannot use \thetitle to print the main title after the first heading, which is unfortunately exactly the thing I had in mind. :/

Workaround to keep the meaning as defined by the titling package: Issue \let\themaintitle\thetitle right after (every) use of \title and use \themaintitle instead.

tl;dr: Both the titling package and this one provide a command \thetitle with different meanings.

I suggest following measures and will happily try to submit a PR once somebody told me which of these would be best (I don't have a lot of experience with authoring packages, I've just been using them as of now 😁 )

  • The least would be putting a notice/heads-up in the manual
  • One could add a package option "nothetitle" (or something like that) which disables the provision of \thetitle by this package. Alternatively a command \nothetitle you can call after the package has been loaded.
  • One could (maybe?) check whether the package titling has been loaded after titlesec and if so, disable the redefinition(s) of \thetitle. This way, you could choose to keep the titlesec-behaviour by loading it after the titling package.

For good measure, here's a MWE:

\documentclass[a4paper]{article}

% Packages
\usepackage{titlesec}
\usepackage{titling}

\title{A Title}
\author{An author}
\date{\today}
% Document
\begin{document}
\maketitle
\section*{First section}
Expected behaviour: \emph{A Title} is printed in the next line\\
\thetitle
\end{document}

Result:
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions