0

I have come across a document where the thesis title and name of the author are above a \chapter*{Abstract} chapter heading. It looks like this:

Text above chapter heading

How can I add custom text like that above a chapter heading?

Below is a MWE, as requested. I'd like the "Title" and "Author" text to be above the chapter heading, just like in the screenshot above.

\documentclass[12pt,a4paper]{book}
\usepackage{lipsum}
\usepackage[parfill]{parskip}

\begin{document}

\chapter*{Abstract}

\textbf{\Large{Title}}

\emph{\large{Author}}

\lipsum[1]

\end{document}

User
  • 3
  • 1
    Welcome to TeX.SE... Please post your MWE from \documentclass to \end{document} – MadyYuvi Jun 14 '22 at 14:44
  • Do you want this above all \chapter and/or \chapter* headings, or just the abstract? Is \maketitle used differently elsewhere, or could/should this be implemented as the \maketitle command? – frabjous Jun 14 '22 at 15:40
  • @frabjous I just need this text above \chapter*{Abstract}. I don't currently use the \maketitle command, so it is not a requirement to implement it as such. – User Jun 14 '22 at 16:31

1 Answers1

0

Here's an implementation based on using the titling package's \thetitle and \theauthor commands (set by \title and \author) to make a new command \abstracttitleandname for printing the title and name above the abstract title.

We also introduce a conditional \ifabstract, set to true by \abstracttitleandname and redefine \chapter/\chapter* commands to check whether it is true. If it is, it won't start the heading on a new page, since \abstractittleandname has already done that. It is then switched back to false.

If the conditional creates problems for you, you could switch from using primitive TeX booleans to one of the more elaborate packages that handle conditionals, but that's probably not necessary for your use case.

\documentclass[12pt,a4paper]{book}
\usepackage{lipsum}
\usepackage[parfill]{parskip}
\usepackage{titling}

\makeatletter % define new boolean conditional switch for whether % the abstract is being typeset \newif\ifabstract \abstractfalse % redefine \chapter so it only starts a new page if not typesetting % the abstract; sets abstract conditional to false after doing so \renewcommand\chapter{\ifabstract\relax\else% \if@openright\cleardoublepage\else\clearpage\fi% \fi \abstractfalse% \thispagestyle{plain}% \global@topnum\z@ @afterindentfalse \secdef@chapter@schapter}

% command for putting the title and name above the abstract; switches % abstact boolean to true for next \chapter* command... \newcommand{\abstracttitleandname}{% \if@openright\cleardoublepage\else\clearpage\fi \textbf{\Large{\thetitle}}\par \emph{\large{\theauthor}}\par \abstracttrue} \makeatother

\author{Someone K. Someone} \title{The Greatest Work}

\begin{document}

\abstracttitleandname \chapter*{Abstract}

\lipsum[1]

\chapter{New chapter}

\lipsum[2]

\end{document}

abstract title example

frabjous
  • 41,473
  • Nice, maybe put \let\abstracttitleandname\@gobble at the end of the command \abstracttitleandname to make it only be used once. – Tom Jun 14 '22 at 18:45