appendix.sty 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. %%
  2. %% This is file `appendix.sty',
  3. %% generated with the docstrip utility.
  4. %%
  5. %% The original source files were:
  6. %%
  7. %% appendix.dtx (with options: `usc')
  8. %%
  9. %% -----------------------------------------------------------------
  10. %% Author: Peter Wilson (CUA) now at peter.r.wilson@boeing.com until June 2004
  11. %% (or at: pandgwilson at earthlink dot net)
  12. %% Copyright 1998 --- 2004 Peter R. Wilson
  13. %%
  14. %% This work may be distributed and/or modified under the
  15. %% conditions of the LaTeX Project Public License, either
  16. %% version 1.3 of this license or (at your option) any
  17. %% later version.
  18. %% The latest version of the license is in
  19. %% http://www.latex-project.org/lppl.txt
  20. %% and version 1.3 or later is part of all distributions of
  21. %% LaTeX version 2003/06/01 or later.
  22. %%
  23. %% This work has the LPPL maintenance status "author-maintained".
  24. %%
  25. %% This work consists of the files listed in the README file.
  26. %% -----------------------------------------------------------------
  27. %%
  28. \NeedsTeXFormat{LaTeX2e}
  29. \ProvidesPackage{appendix}[2002/08/06 v1.2 extra appendix facilities]
  30. \newif\if@chapter@pp\@chapter@ppfalse
  31. \newif\if@knownclass@pp\@knownclass@ppfalse
  32. \@ifundefined{chapter}{%
  33. \@ifundefined{section}{}{\@knownclass@pptrue}}{%
  34. \@chapter@pptrue\@knownclass@pptrue}
  35. \providecommand{\phantomsection}{}
  36. \newcounter{@pps}
  37. \renewcommand{\the@pps}{\alph{@pps}}
  38. \newif\if@pphyper
  39. \@pphyperfalse
  40. \AtBeginDocument{%
  41. \@ifpackageloaded{hyperref}{\@pphypertrue}{}}
  42. \newif\if@dotoc@pp\@dotoc@ppfalse
  43. \newif\if@dotitle@pp\@dotitle@ppfalse
  44. \newif\if@dotitletoc@pp\@dotitletoc@ppfalse
  45. \newif\if@dohead@pp\@dohead@ppfalse
  46. \newif\if@dopage@pp\@dopage@ppfalse
  47. \DeclareOption{toc}{\@dotoc@pptrue}
  48. \DeclareOption{title}{\@dotitle@pptrue}
  49. \DeclareOption{titletoc}{\@dotitletoc@pptrue}
  50. \DeclareOption{header}{\@dohead@pptrue}
  51. \DeclareOption{page}{\@dopage@pptrue}
  52. \ProcessOptions\relax
  53. \newcommand{\@ppendinput}{}
  54. \if@knownclass@pp\else
  55. \PackageWarningNoLine{appendix}%
  56. {There is no \protect\chapter\space or \protect\section\space command.\MessageBreak
  57. The appendix package will not be used}
  58. \renewcommand{\@ppendinput}{\endinput}
  59. \fi
  60. \@ppendinput
  61. \newcommand{\appendixtocon}{\@dotoc@pptrue}
  62. \newcommand{\appendixtocoff}{\@dotoc@ppfalse}
  63. \newcommand{\appendixpageon}{\@dopage@pptrue}
  64. \newcommand{\appendixpageoff}{\@dopage@ppfalse}
  65. \newcommand{\appendixtitleon}{\@dotitle@pptrue}
  66. \newcommand{\appendixtitleoff}{\@dotitle@ppfalse}
  67. \newcommand{\appendixtitletocon}{\@dotitletoc@pptrue}
  68. \newcommand{\appendixtitletocoff}{\@dotitletoc@ppfalse}
  69. \newcommand{\appendixheaderon}{\@dohead@pptrue}
  70. \newcommand{\appendixheaderoff}{\@dohead@ppfalse}
  71. \newcounter{@ppsavesec}
  72. \newcounter{@ppsaveapp}
  73. \setcounter{@ppsaveapp}{0}
  74. \newcommand{\@ppsavesec}{%
  75. \if@chapter@pp \setcounter{@ppsavesec}{\value{chapter}} \else
  76. \setcounter{@ppsavesec}{\value{section}} \fi}
  77. \newcommand{\@pprestoresec}{%
  78. \if@chapter@pp \setcounter{chapter}{\value{@ppsavesec}} \else
  79. \setcounter{section}{\value{@ppsavesec}} \fi}
  80. \newcommand{\@ppsaveapp}{%
  81. \if@chapter@pp \setcounter{@ppsaveapp}{\value{chapter}} \else
  82. \setcounter{@ppsaveapp}{\value{section}} \fi}
  83. \newcommand{\restoreapp}{%
  84. \if@chapter@pp \setcounter{chapter}{\value{@ppsaveapp}} \else
  85. \setcounter{section}{\value{@ppsaveapp}} \fi}
  86. \providecommand{\appendixname}{Appendix}
  87. \newcommand{\appendixtocname}{Appendices}
  88. \newcommand{\appendixpagename}{Appendices}
  89. \newcommand{\appendixpage}{%
  90. \if@chapter@pp \@chap@pppage \else \@sec@pppage \fi
  91. }
  92. \newcommand{\clear@ppage}{%
  93. \if@openright\cleardoublepage\else\clearpage\fi}
  94. \newcommand{\@chap@pppage}{%
  95. \clear@ppage
  96. \thispagestyle{plain}%
  97. \if@twocolumn\onecolumn\@tempswatrue\else\@tempswafalse\fi
  98. \null\vfil
  99. \markboth{}{}%
  100. {\centering
  101. \interlinepenalty \@M
  102. \normalfont
  103. \Huge \bfseries \appendixpagename\par}%
  104. \if@dotoc@pp
  105. \addappheadtotoc
  106. \fi
  107. \vfil\newpage
  108. \if@twoside
  109. \if@openright
  110. \null
  111. \thispagestyle{empty}%
  112. \newpage
  113. \fi
  114. \fi
  115. \if@tempswa
  116. \twocolumn
  117. \fi
  118. }
  119. \newcommand{\@sec@pppage}{%
  120. \par
  121. \addvspace{4ex}%
  122. \@afterindentfalse
  123. {\parindent \z@ \raggedright
  124. \interlinepenalty \@M
  125. \normalfont
  126. \huge \bfseries \appendixpagename%
  127. \markboth{}{}\par}%
  128. \if@dotoc@pp
  129. \addappheadtotoc
  130. \fi
  131. \nobreak
  132. \vskip 3ex
  133. \@afterheading
  134. }
  135. \newif\if@pptocpage
  136. \@pptocpagetrue
  137. \newcommand{\noappendicestocpagenum}{\@pptocpagefalse}
  138. \newcommand{\appendicestocpagenum}{\@pptocpagetrue}
  139. \newcommand{\addappheadtotoc}{%
  140. \phantomsection
  141. \if@chapter@pp
  142. \if@pptocpage
  143. \addcontentsline{toc}{chapter}{\appendixtocname}%
  144. \else
  145. \if@pphyper
  146. \addtocontents{toc}%
  147. {\protect\contentsline{chapter}{\appendixtocname}{}{\@currentHref}}%
  148. \else
  149. \addtocontents{toc}%
  150. {\protect\contentsline{chapter}{\appendixtocname}{}}%
  151. \fi
  152. \fi
  153. \else
  154. \if@pptocpage
  155. \addcontentsline{toc}{section}{\appendixtocname}%
  156. \else
  157. \if@pphyper
  158. \addtocontents{toc}%
  159. {\protect\contentsline{section}{\appendixtocname}{}{\@currentHref}}%
  160. \else
  161. \addtocontents{toc}%
  162. {\protect\contentsline{section}{\appendixtocname}{}}%
  163. \fi
  164. \fi
  165. \fi
  166. }
  167. \providecommand{\theH@pps}{\alph{@pps}}
  168. \newcommand{\@resets@pp}{\par
  169. \@ppsavesec
  170. \stepcounter{@pps}
  171. \setcounter{section}{0}%
  172. \if@chapter@pp
  173. \setcounter{chapter}{0}%
  174. \renewcommand\@chapapp{\appendixname}%
  175. \renewcommand\thechapter{\@Alph\c@chapter}%
  176. \else
  177. \setcounter{subsection}{0}%
  178. \renewcommand\thesection{\@Alph\c@section}%
  179. \fi
  180. \if@pphyper
  181. \if@chapter@pp
  182. \renewcommand{\theHchapter}{\theH@pps.\Alph{chapter}}%
  183. \else
  184. \renewcommand{\theHsection}{\theH@pps.\Alph{section}}%
  185. \fi
  186. \def\Hy@chapapp{\appendixname}%
  187. \fi
  188. \restoreapp
  189. }
  190. \newenvironment{appendices}{%
  191. \@resets@pp
  192. \if@dotoc@pp
  193. \if@dopage@pp % both page and toc
  194. \if@chapter@pp % chapters
  195. \clear@ppage
  196. \fi
  197. \appendixpage
  198. \else % toc only
  199. \if@chapter@pp % chapters
  200. \clear@ppage
  201. \fi
  202. \addappheadtotoc
  203. \fi
  204. \else
  205. \if@dopage@pp % page only
  206. \appendixpage
  207. \fi
  208. \fi
  209. \if@chapter@pp
  210. \if@dotitletoc@pp \@redotocentry@pp{chapter} \fi
  211. \else
  212. \if@dotitletoc@pp \@redotocentry@pp{section} \fi
  213. \if@dohead@pp
  214. \def\sectionmark##1{%
  215. \if@twoside
  216. \markboth{\@formatsecmark@pp{##1}}{}
  217. \else
  218. \markright{\@formatsecmark@pp{##1}}{}
  219. \fi}
  220. \fi
  221. \if@dotitle@pp
  222. \def\sectionname{\appendixname}
  223. \def\@seccntformat##1{\@ifundefined{##1name}{}{\csname ##1name\endcsname\ }%
  224. \csname the##1\endcsname\quad}
  225. \fi
  226. \fi}{%
  227. \@ppsaveapp\@pprestoresec}
  228. \newcommand{\setthesection}{\thechapter.\Alph{section}}
  229. \newcommand{\setthesubsection}{\thesection.\Alph{subsection}}
  230. \newcommand{\@resets@ppsub}{\par
  231. \stepcounter{@pps}
  232. \if@chapter@pp
  233. \setcounter{section}{0}
  234. \renewcommand{\thesection}{\setthesection}
  235. \else
  236. \setcounter{subsection}{0}
  237. \renewcommand{\thesubsection}{\setthesubsection}
  238. \fi
  239. \if@pphyper
  240. \if@chapter@pp
  241. \renewcommand{\theHsection}{\theH@pps.\setthesection}%
  242. \else
  243. \renewcommand{\theHsubsection}{\theH@pps.\setthesubsection}%
  244. \fi
  245. \def\Hy@chapapp{\appendixname}%
  246. \fi
  247. }
  248. \newenvironment{subappendices}{%
  249. \@resets@ppsub
  250. \if@chapter@pp
  251. \if@dotitletoc@pp \@redotocentry@pp{section} \fi
  252. \if@dotitle@pp
  253. \def\sectionname{\appendixname}
  254. \def\@seccntformat##1{\@ifundefined{##1name}{}{\csname ##1name\endcsname\ }%
  255. \csname the##1\endcsname\quad}
  256. \fi
  257. \else
  258. \if@dotitletoc@pp \@redotocentry@pp{subsection} \fi
  259. \if@dotitle@pp
  260. \def\subsectionname{\appendixname}
  261. \def\@seccntformat##1{\@ifundefined{##1name}{}{\csname ##1name\endcsname\ }%
  262. \csname the##1\endcsname\quad}
  263. \fi
  264. \fi}{}
  265. \newcommand{\@formatsecmark@pp}[1]{%
  266. \MakeUppercase{\appendixname\space
  267. \ifnum \c@secnumdepth >\z@
  268. \thesection\quad
  269. \fi
  270. #1}}
  271. \newcommand{\@redotocentry@pp}[1]{%
  272. \let\oldacl@pp=\addcontentsline
  273. \def\addcontentsline##1##2##3{%
  274. \def\@pptempa{##1}\def\@pptempb{toc}%
  275. \ifx\@pptempa\@pptempb
  276. \def\@pptempa{##2}\def\@pptempb{#1}%
  277. \ifx\@pptempa\@pptempb
  278. \oldacl@pp{##1}{##2}{\appendixname\space ##3}%
  279. \else
  280. \oldacl@pp{##1}{##2}{##3}%
  281. \fi
  282. \else
  283. \oldacl@pp{##1}{##2}{##3}%
  284. \fi}
  285. }
  286. \endinput
  287. %%
  288. %% End of file `appendix.sty'.