Latex: Autorennamen je chapter, section, subsection

In den header-Teil:

%\PassOptionsToPackage{bookmarksopen,
%pdfstartview={Fit},
%colorlinks=true,
%linkcolor=blue,
%urlcolor=blue,
%citecolor=blue,
%plainpages=false,
%pdfpagelabels}{hyperref}
\makeatletter
\g@addto@macro{\maketitle}{\def\author#1{\def\@author{#1}}}
\newcommand*{\extendsectlevel}[1]{%
  \expandafter\newcommand\expandafter*\csname saved@#1\endcsname{}%
  \expandafter\let\csname saved@#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\renewcommand\expandafter*\csname #1\endcsname{%
    \expandafter\let\csname author@#1\endcsname\@author
    \@ifstar
      {\csname star@#1\endcsname}%
      {\@dblarg{\csname opt@#1\endcsname}}%
  }%
  \expandafter\newcommand\expandafter*\csname star@#1\endcsname[1]{%
    \csname saved@#1\endcsname*{##1%
      \expandafter\ifx\csname author@#1\endcsname\@empty\else
        \hfill\linebreak{\normalsize
          \textmd{\textit{\csname author@#1\endcsname}}}%
      \fi
    }%
  }%
  \expandafter\newcommand\expandafter*\csname opt@#1\endcsname[2][]{%
    \csname saved@#1\endcsname[{##1%
      \expandafter\ifx\csname author@#1\endcsname\@empty\else
%        \enskip\textmd{\textit{(\csname author@#1\endcsname)}}%
% >>> UN/COMMENT the above line to enable/disable author names in the TOC
      \fi
    }]{##2%
      \expandafter\ifx\csname author@#1\endcsname\@empty\else
        \hfill\linebreak{\normalsize
          \textmd{\textit{\csname author@#1\endcsname}}}%
      \fi
    }%
  }%
}
\extendsectlevel{chapter}
\extendsectlevel{section}
\extendsectlevel{subsection}
\makeatother

Beispiel:

\begin{document}
    \title{test}
    
    \author{Man A}
    \maketitle
    \tableofcontents

    \author{Author of Chapter 1 and following chapters/sections}
    \chapter{Chapter 1}
        \section{Section 1.1}
            \subsection{Subsection 1.1.1}

    \author{Author of Chapter 2}
    \chapter{Chapter 2}
        \author{Author of Section 2.1}
        \section{Section 2.1}
            \author{Author of Subsection 2.1.1}
            \subsection{Subsection 2.1.1}

 % >>> RESET AFTER YOUR PARTS WITH \author{}

\end{document}

(von komascript.de)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.