I am using the \@author
command from the authblk
package on Overleaf to list chapter authors per chapter without creating a new title page every time (example below). This works, but as soon as I include the \@author
command, all figure captions in the chapter get misplaced. Does anyone know how this could happen? The author command and figures are completely unrelated as far as I'm aware (but apparently not), so I don't even know where to begin to try and solve this...
Or alternatively, does anyone have suggestions for another way besides \@author
to show the authors and affiliations per chapter without using \maketitle?
\documentclass[12pt,twoside, notitlepage]{book}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}
\usepackage[dutch,main=english]{babel}
\usepackage{csquotes}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.~\MakeUppercase{#1}}{}}
\fancyhead[LO,RE]{\textsl{\leftmark}} %<--- use [t] for parbox.
\fancyhead[LE,RO]{\thepage} %<--- better use [t] here also for parbox to ensure that alignment.
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}}
\usepackage{graphicx}
\graphicspath{ {graphics/} }
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{authblk}
\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{xspace}
\usepackage{hyperref}
\usepackage[capitalise,noabbrev,dutch,english]{cleveref}
\usepackage{subcaption}
\renewcommand\thesubfigure{\Alph{subfigure}}
\usepackage{float}
\usepackage{listings}
\newfloat{lstfloat}{htbp}{lop}
\floatname{lstfloat}{Listing}
\def\lstfloatautorefname{Listing}
\crefalias{lstfloat}{listing}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
frame=single,
breaklines=true,
}
\usepackage{booktabs}
\usepackage[style=nature,sorting=none,giveninits=true,uniquename=init]{biblatex}
\setcounter{biburlnumpenalty}{7000}
\setcounter{biburllcpenalty}{7000}
\setcounter{biburlucpenalty}{8000}
\newcommand{\publicationcite}[1]{\AtNextCite{\defcounter{maxnames}{99}}\fullcite{#1}}
\newcommand\abstractname{Abstract}
\makeatletter
\newenvironment{abstract}{%
\if@twocolumn
\section*{\abstractname}%
\else
\small
\begin{center}%
{\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
\end{center}%
\quotation
\fi}
{\if@twocolumn\else\endquotation\fi}
\makeatother
\begin{document}
\begin{titlepage}
\begin{center}
Titlepage
\vfill
titlepage footer
\end{center}
\end{titlepage}
\makeatletter
\renewcommand{\@tocrmarg}{2.55em plus1fil}
\makeatletter
\tableofcontents
\begin{refsection}
\chapter[Chapter2]{Chapter2}
\label{ch:cold}
\author[1]{Author 1}
\affil[1]{Affil 1}
\makeatletter
\@author %without this line, the figure captions are displayed properly
\makeatother
Main text of chapter, with figures.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{figurefile.png}
\caption{This is a test caption}
\label{fig:fig1}
\end{figure}
\lipsum[]
\clearpage
\lipsum[]
\ref{fig:fig1}
%\printbibliography[title=References]
\end{refsection}
\end{document}
You can avoid the problem by placing \@author
in some kind of box, e.g. a minipage
:
\documentclass{book}
\usepackage[noblocks]{authblk}
\usepackage{graphicx}
\begin{document}
\author[1]{Author 1}
\affil[1]{Affil 1}
\noindent\begin{minipage}{\linewidth}
\makeatletter
\@author
\makeatother
\end{minipage}
Main text of chapter, with figures.
\begin{figure}[h]
\centering
\includegraphics[width=.8\linewidth]{mouse.jpg}
\caption{This is a test caption}
\label{fig:mouse}
\end{figure}
test
\end{document}