我需要将个别章节作者的姓名放在章节标题上方。
\@afterheading
用于将作者姓名放在章节标题之后。我会尝试使用\@beforeheading%
其他方法。但宏没有运行。请指教如何将作者姓名放在章节标题toc
和章节开头页之前。
梅威瑟:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{suffix}
\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}}
\WithSuffix\newcommand\chapterauthor*[1]{\printchapterauthor{#1}}
\makeatletter
\newcommand{\printchapterauthor}[1]{%
{\parindent0pt\vspace*{-25pt}%
\linespread{1.1}\large\scshape#1%
\par\nobreak\vspace*{35pt}}
\@afterheading%
}
\newcommand{\authortoc}[1]{%
\addtocontents{toc}{\vskip-10pt}%
\addtocontents{toc}{%
\protect\contentsline{chapter}%
{\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
\addtocontents{toc}{\vskip5pt}%
}
\makeatother
\begin{document}
\tableofcontents
\chapter{1st chapter}
\chapterauthor{K.DINESH KUMAR}
\lipsum[1]
\end{document}
答案1
我建议为此类标题定义一个新命令,该命令接受两个参数:标题和作者。该宏本质上应该只是调用\chapter
作者,然后是标题,但会包装成适当的格式命令以满足您的需求。例如:
\documentclass[12pt]{book}
\usepackage{lipsum}
\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}}
\newcommand{\printchapterauthor}[1]{%
{\textnormal{\large\scshape#1}\\[2ex]}}
\newcommand{\authortoc}[1]{%
\addtocontents{toc}{\vskip-10pt}%
\addtocontents{toc}{%
\protect\contentsline{chapter}%
{\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
\addtocontents{toc}{\vskip5pt}%
}
\newcommand{\chapterwithauthor}[2]{\chapter[#1]{\printchapterauthor{#2}#1}\authortoc{#2}\markboth{#2}{#1}}
\begin{document}
\tableofcontents
\chapterwithauthor{1st chapter}{K.~DINESH KUMAR}
\lipsum[1-10]
\end{document}