3

An attempt to use the package titling with the class letter:

\documentclass{letter}

\usepackage{titling}

\title{Title} \author{Author} \date{\today}

\begin{document}

\thetitle\par \theauthor\par \thedate\par Text.

\end{document}

results in errors indicating that they are incompatible:

Undefined control sequence. \if@titlepage
Extra \else. \else
Extra \fi. \fi
Extra \fi.

This can be avoided by, e.g., not invoking titling and instead referring to \@title, \@author, and \@date.

Nevertheless, I am interested if there is a way to patch some of the conflicting class/package definitions to maintain the possibility to use the macros provided by titling in letter? I have not found any information about this matter neither in the documentation of the class and the package nor on TeX.SX.

Peter
  • 998
  • Unrelated: scrletter package could be an alternative solution (https://tex.stackexchange.com/questions/18033/using-bibtex-with-letter-class). – Cicada Dec 20 '20 at 08:23
  • Why specifically do you want to use the letter class? You can perform similar layouts using just article. If you want to show what you're after, one can reproduce it. – Werner Dec 20 '20 at 17:39
  • I am currently editing several documents of newlfm class (that inherits this problem after letter). They use its features like \newlfmP, \addr…, \name… \closeline or \psitem. It is possible to recreate them using article, although the effort needed to achieve satisfactory results for a few documents in different layouts would be incomparably higher than just giving up on titling and using \@title etc. I was just curious about the reason for this incompatibility, as sometimes just a single use of, e.g., \patchcommand could solve such errors. – Peter Dec 20 '20 at 20:57

1 Answers1

3

All the basic document classes (article, book and report), except for letter (and minimal) define the option to have a title page with an accompanying conditional \if@titlepage. Since letter doesn't declare this conditional, you can intervene:

enter image description here

\documentclass{letter}

% Define conditional used by most document classes \expandafter\newif\csname if@titlepage\endcsname \usepackage{titling}

\title{A title} \author{An author} \date{\today}

\begin{document}

\thetitle\par \theauthor\par \thedate\par Text.

\end{document}

Werner
  • 603,163