1

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}

This is what happens on any page that has a figure: enter image description here

Koalabear
  • 110
  • 1
  • 6
  • Your code is missing several packages necessary to compile your code fragment. Please check such things before posting. – samcarter_is_at_topanswers.xyz Jun 10 '23 at 12:05
  • Added the full preamble – Koalabear Jun 10 '23 at 12:12
  • You should use ` \makeatletter \@author \makeatother` and you must not leave the argument of `\includegraphics{}` empty. Other than that, please specify what you mean that the captions are misplaced. Can you add a screenshot? – samcarter_is_at_topanswers.xyz Jun 10 '23 at 12:22
  • I get all the images including their captions at the end, which is expected for figures without floating specifiers. – samcarter_is_at_topanswers.xyz Jun 10 '23 at 12:23
  • Adding the ` \makeatletter \@author \makeatother` doesn't change anything for me. I added a screenshot to the original post. Now it is all text, not just the caption anymore for some reason (I haven't changed anything since posting here) – Koalabear Jun 10 '23 at 12:37
  • The code from your question does not reproduce this output. – samcarter_is_at_topanswers.xyz Jun 10 '23 at 12:42
  • That is so strange... The only difference between this code and mine is that I removed people's personal details and that there are eight chapters instead of one... I even added a some lipsum to the caption and the text in the code above to double check, but if I copy-paste this into a new Overleaf document I get the same problem... https://www.overleaf.com/7778133613svxngjndhyvf – Koalabear Jun 10 '23 at 13:19
  • might be the same problem as in https://github.com/rrthomas/crop/issues/2 – samcarter_is_at_topanswers.xyz Jun 10 '23 at 14:51
  • FYI: earlier revisions of your question did not reproduce the problem because they did not use the `width` key for `\includegraphics` – samcarter_is_at_topanswers.xyz Jun 10 '23 at 15:06
  • Thinking about it, why do you want to use `\author` etc. for chapter authors? All the goodies of a global `\author`, like setting the pdf meta data aren't relevant to this usage. You could just use a custom macro to format the author and affiliation of chapter authors. – samcarter_is_at_topanswers.xyz Jun 10 '23 at 15:14
  • Ah so that is the issue... I don't necessarily need to use that command, but from what I found online that is the only package that does it... I have never built a custom macro before, not sure how to do that. Right now I am manually changing the format in every chapter individually to get around the issue and that works, but I figured there has to be a more elegant solution... – Koalabear Jun 10 '23 at 21:23
  • The minipage worked, thanks! – Koalabear Jun 10 '23 at 21:57

1 Answers1

1

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}