5

I'm trying to compile an scrbook and what I would like is to shon an author with affiliation for each chapter. The authblk package allows us to do this for the title.

Is there anyway to adapt it to chapters? I've tried different things, but most didn't work out. Does anyone maybe have a working piece of tex?

This is how I imagine it to work (this is no working example, just an illustration:

\documentclass{scrbook}
\begin{document}

\title{My Book}
\author{F. D. C. Willard}
\chapter{Chapter 1}
 \chapterauthor[1]{Don Joe}
 \chapterauthor[1]{F. D. C. Willard}
 \chapteraffil[1]{TeX Stackexchange School}

\chapter{Chapter 2}
 \chapterauthor[1]{John Doe}
 \chapterauthor[1]{Jane Doe}
 \chapterauthor[2]{Albert Einstein}
 \chapterauthor[3]{Pepe Frog}
 \chapterauthor[3]{Willy Wonka}
 \chapteraffil[1]{Harvard University}
 \chapteraffil[2]{Tex School}
 \chapteraffil[3]{High School 4C District}

 \end{document}

This should end up like this and additionally showing the author names and additionally a list of affiliations like this: enter image description here

In the TOC I would just like to show a comma separated list of authors.

I've added the bounty b/c my tries just failed.

8
+200

No package (apart hyperref), simple minded. Needs to be customized probably.

Note: a solution without extra mark-up with affils environment is possible, but this one is easier to customize via enumitem for example for the list of affiliations.

edit

I have added variant using \sffamily, suppressing indentation of first paragraph following list of affiliations and controlling vertical space using enumitem for it.


\documentclass{scrbook}

\usepackage{hyperref}
\newif\ifnewauthor
\newauthortrue

\newcounter{affils}

\makeatletter
\def\chapterauthor[#1]#2{\ifnewauthor\else, \fi
       #2\textsuperscript{\hyperref[authaffil\the\value{chapter}.#1]{#1}}%
       \ifnewauthor\newauthorfalse\gdef\chapterauthors{#2}\else
               \g@addto@macro\chapterauthors{, #2}\fi
       \ignorespaces % to remove end of line spaces from
                     % \chapterauthor[foo]{bar} input lines
}
\makeatother

\def\chapteraffil[#1]{\item[#1 --]%
    \refstepcounter{affils}%
    \label{authaffil\the\value{chapter}.#1}%
}

\newenvironment{affils}
   {\addtocontents{toc}{\chapterauthors\string\par}\begin{enumerate}}
   {\end{enumerate}\global\newauthortrue}


\begin{document}

\title{My Book}
\author{F. D. C. Willard}
\maketitle

\tableofcontents

\chapter{Chapter 1}
 \chapterauthor[1]{Don Joe}
 \chapterauthor[1]{F. D. C. Willard}
 \begin{affils}
   \chapteraffil[1]{TeX Stackexchange School}
 \end{affils}

\chapter{Chapter 2}
 \chapterauthor[1]{John Doe}
 \chapterauthor[1]{Jane Doe}
 \chapterauthor[2]{Albert Einstein}
 \chapterauthor[3]{Pepe Frog}
 \chapterauthor[3]{Willy Wonka}
 \begin{affils}
   \chapteraffil[1]{Harvard University}
   \chapteraffil[2]{Tex School}
   \chapteraffil[3]{High School 4C District}
 \end{affils}

\end{document}

TOC:

enter image description here

CHAPTERS:

enter image description here

enter image description here


Updated code

\documentclass{scrbook}

\usepackage{enumitem, hyperref}
\newif\ifnewauthor
\newauthortrue

\newcounter{affils}

\makeatletter
\def\chapterauthor[#1]#2{\ifnewauthor\sffamily\else, \fi
       #2\textsuperscript{\hyperref[authaffil\the\value{chapter}.#1]{#1}}%
       \ifnewauthor\newauthorfalse\gdef\chapterauthors{#2}\else
               \g@addto@macro\chapterauthors{, #2}\fi
       \ignorespaces % to remove end of line spaces from
                     % \chapterauthor[foo]{bar} input lines
}
\makeatother

\def\chapteraffil[#1]{\item[#1 --]%
    \refstepcounter{affils}%
    \label{authaffil\the\value{chapter}.#1}%
}

\makeatletter
\newenvironment{affils}
   {\addtocontents{toc}{\chapterauthors\string\par}%
    \begin{itemize}[itemsep=0pt, parsep=0pt]}
   {\end{itemize}\par
    \global\newauthortrue
    \@nobreaktrue
    \aftergroup\normalfont}
\makeatother


\begin{document}

\title{My Book}
\author{F. D. C. Willard}
\maketitle

\tableofcontents

\chapter{Chapter 1}

 \chapterauthor[1]{Don Joe}
 \chapterauthor[1]{F. D. C. Willard}
 \begin{affils}
   \chapteraffil[1]{TeX Stackexchange School}
 \end{affils}

No indentation for this first text paragraph.


\chapter{Chapter 2}

 \chapterauthor[1]{John Doe}
 \chapterauthor[1]{Jane Doe}
 \chapterauthor[2]{Albert Einstein}
 \chapterauthor[3]{Pepe Frog}
 \chapterauthor[3]{Willy Wonka}
 \begin{affils}
   \chapteraffil[1]{Harvard University}
   \chapteraffil[2]{Tex School}
   \chapteraffil[3]{High School 4C District}
 \end{affils}

And this text is with ``normal font'' settings.

\end{document}

Produces

enter image description here

enter image description here

  • Thanks @jfbu - this really helped me out. I'm making a book in latex..my first book, but hey I'm getting there. The code you wrote works perfect. I've changed it so the the authors show up as ssfamily in the toc. Unfortunately now the whole toc shows up like that ^^ - maybe a hint. I thought I could just add that in this line {\addtocontents{toc}{\chapterauthors\string\par}? – nhck Sep 11 '17 at 18:11
  • @nhck try \addtocontents{toc}{{\sffamily\chapterauthors}\string\par} – user4686 Sep 11 '17 at 18:56
  • thanks - this Tex-Scripting language is mysterious sometimes ;-) Works like a charm. Imho this whole thing should be a package :-) An extension of authblk would be awesome. Again: Thanks so much! You helped me a lot. – nhck Sep 12 '17 at 8:08
  • How would you handle multiple affiliations per author? If I just insert a comma separated list, the hyperlinking breaks. – Ohjeah Jan 19 '18 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.