我正在为一本艺术杂志创建目录。目录应按作品类型(诗歌、非小说、小说、视觉艺术)对作品进行分组,但材料将混合在杂志中(诗歌页数:1、5、8、12 非小说页数:2、7、13 等)。它将以电子形式发布,我仍然希望人们能够点击作品并直接进入页面。
答案1
以下是使用四份副本来实现此目的的一种方法\section
:
\poesection
对于诗歌。\nofisection
非小说类作品。\fisection
对于小说作品。\vasection
视觉艺术作品。
memoir
这些命令中的每一个都与标准的命令完全相同\section
(特别是,您可以为每个命令使用三个参数),只是每个命令都会将目录信息写入指定文件。该命令\TableOfContents
会生成分组的目录。
代码:
\documentclass{memoir}
\usepackage{xparse}
\usepackage{letltxmacro}
\usepackage[colorlinks=true]{hyperref}
\makeatletter
\LetLtxMacro\poesection\section
\LetLtxMacro\nofisection\section
\LetLtxMacro\fisection\section
\LetLtxMacro\vasection\section
\RenewDocumentCommand\fisection{oom}{
\IfNoValueTF{#1}
{\section{#3}\addcontentsline{lfi}{section}{\numberline{\thesection}#3}}
{
\IfNoValueTF{#2}
{\section[#1]{#3}\addcontentsline{lfi}{section}{\numberline{\thesection}#1}}
{\section[#1][#2]{#3}\addcontentsline{lfi}{section}{\numberline{\thesection}#1}}
}
}
\RenewDocumentCommand\nofisection{oom}{
\IfNoValueTF{#1}
{\section{#3}\addcontentsline{lnf}{section}{\numberline{\thesection}#3}}
{
\IfNoValueTF{#2}
{\section[#1]{#3}\addcontentsline{lnf}{section}{\numberline{\thesection}#1}}
{\section[#1][#2]{#3}\addcontentsline{lnf}{section}{\numberline{\thesection}#1}}
}
}
\RenewDocumentCommand\vasection{oom}{
\IfNoValueTF{#1}
{\section{#3}\addcontentsline{lva}{section}{\numberline{\thesection}#3}}
{
\IfNoValueTF{#2}
{\section[#1]{#3}\addcontentsline{lva}{section}{\numberline{\thesection}#1}}
{\section[#1][#2]{#3}\addcontentsline{lva}{section}{\numberline{\thesection}#1}}
}
}
\RenewDocumentCommand\poesection{oom}{
\IfNoValueTF{#1}
{\section{#3}\addcontentsline{lpo}{section}{\numberline{\thesection}#3}}
{
\IfNoValueTF{#2}
{\section[#1]{#3}\addcontentsline{lpo}{section}{\numberline{\thesection}#1}}
{\section[#1][#2]{#3}\addcontentsline{lpo}{section}{\numberline{\thesection}#1}}
}
}
\newcommand\vacontentsname{Visual Art}
\newcommand\tableofvacontents{%
\section*{\vacontentsname}
\@starttoc{lva}%
}
\newcommand\noficontentsname{Non Fiction}
\newcommand\tableofnoficontents{%
\section*{\noficontentsname}
\@starttoc{lnf}%
}
\newcommand\ficontentsname{Fiction}
\newcommand\tableofficontents{%
\section*{\ficontentsname}
\@starttoc{lfi}%
}
\newcommand\poemcontentsname{Poetry}
\newcommand\tableofpoemcontents{%
\section*{\poemcontentsname}
\@starttoc{lpo}%
}
\newcommand\generalcontentsname{General Contents}
\newcommand\TableOfContents{
\begingroup
\pagestyle{plain}
\section*{\generalcontentsname}
\tableofficontents
\tableofnoficontents
\tableofvacontents
\tableofpoemcontents
\endgroup
}
\makeatother
\begin{document}
\TableOfContents
\clearpage
\fisection{Another fiction work}
\nofisection{A first non-fiction work}
\vasection{Yet another visual art work}
\clearpage
\setcounter{page}{13}
\poesection{A first test poem}
\clearpage
\vasection{Another visual work}
\poesection{Yet another test poem}
\fisection{A first fiction work}
\clearpage
\setcounter{page}{25}
\nofisection{Yet another non-fiction work}
\fisection{Yet another fiction work}
\clearpage
\vasection{A first visual work}
\nofisection{Another non-fiction work}
\poesection{Another test poem}
\end{document}
最终的目录如下: