2点質問させて下さい。
AppendixをTable of Contents に下記のようにAppendixの開始ページのみ表示させるにはどうすればよいでしょうか?
Appendixのリストを下記のように図や表と同じように追加するにはどのようにすれば良いのでしょうか?
Table of Contents
Chap1......................1
Chap2......................10
Chap3......................20
Appendix...................30
List of Figure
Fig1.......................4
Fig2.......................7
List of Table
Tab1.......................10
List of Appendices
App1.......................30
App2.......................40
appendixパッケージを使ってみましたがうまくいきませんでした。
"List of Appendices"の文字列を表示することはできましたが、肝心の中身をつくることができませんでした。listoffiguresみたいにしてAppendixも追加できないでしょうか?
# 他の方からの回答があるまでの「つなぎ」として,書き込んでおきます.
appendix パッケージには,List of Figures のように List of Appendices を作るという機能はないようですね.
最初 \ifx \@chapapp \appendixname として場合を分けようとしてうまくいかずハマりました.
book.cls でしか試していませんので,日本語のクラスファイルの場合には適宜修正が必要かも知れません.
(*) で示した部分で場合分けをして,appendix 以外では .toc に目次項目を送って, appendixでは .loa (list of appendices) に目次項目を送っています.
List of Appendices の体裁は,\l@chapter, \l@section のままですので,Table of Contents と同じ体裁になります.List of Figures 等に揃えたい場合には,適宜再定義してください.
提示されているサンプルに合わせるために,tocloft パッケージを使っています(手抜きです).
\documentclass[openany]{book}
\makeatletter
% appendix かどうかの条件判断のために \if@appendix を導入
\newif\if@appendix \@appendixfalse
% \chapter を変更(book.cls からコピー)
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\if@appendix\def\tocloa{loa}\else\def\tocloa{toc}\fi% (*)
\addcontentsline{\tocloa}{chapter}% % (*)
{\protect\numberline{%
\if@appendix App\else Chap\fi
~\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
% \section を変更(latex.ltx からコピー)
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\if@appendix\def\tocloa{loa}\else\def\tocloa{toc}\fi% (*)
\addcontentsline{\tocloa}{#1}{% % (*)
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\if@appendix\def\tocloa{loa}\else\def\tocloa{toc}\fi% (*)
\addcontentsline{\tocloa}{#1}{% % (*)
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}
% \listofappendices を新設(book.cls から \listoffigures/\listoftables をコピー)
\newcommand\listofappendices{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listappendixname}%
\@mkboth{%
\MakeUppercase\appendixname}%
{\MakeUppercase\appendixname}%
\@starttoc{loa}%
\if@restonecol\twocolumn\fi
}
\newcommand{\listappendixname}{List of Appendices}
% \appendix のときに \@appendixtrue となるように追加
\renewcommand\appendix{\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\gdef\@chapapp{\appendixname}%
%\gdef\thechapter{\@Alph\c@chapter}% App. 1 にされたいようですので
\global\@appendixtrue%
}
% \backmatter では \@appendixfalse に戻しておく
\renewcommand{\backmatter}{%
\if@openright \cleardoublepage \else \clearpage \fi
\@mainmatterfalse
\global\@appendixfalse}
\makeatother
% 以下は appandix とは関係ありません
\usepackage{tocloft}
\renewcommand{\cftfigpresnum}{Fig~}
\renewcommand{\cfttabpresnum}{Tab~}
\cftsetindents{figure}{0em}{3.5em}
\cftsetindents{table}{0em}{3.5em}
\renewcommand\contentsname{Table of Contents}
\begin{document}
\tableofcontents\newpage% \newpage が必要なのは tocloft のせいです
\listoffigures\newpage% 同上
\listoftables
\listofappendices
\chapter{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\chapter{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\chapter{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\appendix
\chapter{}
\addcontentsline{toc}{chapter}{\appendixname}
% ここで toc に \appendixname を送ります
\section{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\section{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\chapter{}
\section{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\section{}
\begin{figure}\caption{}\end{figure}
\begin{table}\caption{}\end{table}
\end{document}
> 私が現在使っているのはarticle classなのですが、その際どのように変更すればよいのでしょうか?
book.cls からコピーしていた部分を article.cls からコピーして書き直せばいいだけですよ.
# もっといい方法をどなたかが回答してくださるかも知れませんが.
\documentclass{article}
\makeatletter
\newif\if@appendix \@appendixfalse
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\if@appendix\def\tocloa{loa}\else\def\tocloa{toc}\fi% (*)
\addcontentsline{\tocloa}{#1}{% % (*)
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\if@appendix\def\tocloa{loa}\else\def\tocloa{toc}\fi% (*)
\addcontentsline{\tocloa}{#1}{% % (*)
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}
\newcommand\listofappendices{%
\section*{\listappendixname}%
\@mkboth{\MakeUppercase\listappendixname}%
{\MakeUppercase\listappendixname}%
\@starttoc{loa}%
}
\newcommand{\listappendixname}{List of Appendices}
\renewcommand\appendix{\par
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\gdef\thesection{\@Alph\c@section}%
\global\@appendixtrue}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\makeatletter\let\l@section\l@figure\makeatother
\listofappendices
\newpage
\section{}
\begin{figure}\caption{}\end{figure}
\section{}
\begin{table}\caption{}\end{table}
\appendix
\section{}
\addcontentsline{toc}{section}{\appendixname}
\section{}
\end{document}