tlhypref.sty 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. %
  2. % This package complements the thloria class and is aimed to replace
  3. % the hyperref package in this context. The hyperref package does not
  4. % address the intricacies of thloria and this is what we are doing here.
  5. % This package load hyperref and passes its options so that one can write
  6. % \usepackage[pdftex]{tlhypref} or whatever.
  7. %
  8. % Versions:
  9. % 0.92 (1999/04/08): added a fourth parameter to \@writetorep to make it
  10. % again compatible with hyperref.sty.
  11. % Needs hyperref 6.53 or later.
  12. % 0.93 (1999/07/13): again compatible with hyperref 6.63;
  13. % use of higher-level commands.
  14. % \TLpdfbookmark removed (use \texorpdfstring)
  15. % 0.94 (1999/07/15): \@toc@hook added
  16. %
  17. \def\fileversion{0.94}
  18. \def\filedate{1999/07/15}
  19. \NeedsTeXFormat{LaTeX2e}
  20. \ProvidesPackage{tlhypref}[\filedate\space\fileversion\space
  21. thloria wrapper for hyperref package (D. Roegel)]
  22. \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{hyperref}}
  23. \ProcessOptions
  24. \RequirePackage{hyperref}
  25. % We cancel modifications from hyperref (in hpdftex.def and pdftex.def).
  26. \let\@sect\H@old@sect
  27. \let\@schapter\H@old@schapter
  28. \let\@spart\H@old@spart
  29. \let\refstepcounter\H@refstepcounter
  30. % Now, \@part, \@chapter, \@sect and \refstepcounter have the good values
  31. % of thloria.
  32. % Addition of \TLtopbookmark in front of \tableofcontents
  33. % in order to make sure that the bookmark entry for the table of contents
  34. % is at the top level. Works with the chapter hook.
  35. \let\@old@tableofcontents\tableofcontents
  36. \def\tableofcontents{\TLtopbookmark\@old@tableofcontents}
  37. % These definitions are for the purpose of comparisons in \refstepcounter:
  38. \def\@partcountername{part}
  39. \def\@chaptercountername{chapter}
  40. \def\@annexcountername{annex}
  41. % \refstepcounter is redefined so that \@currentHref is uptodate
  42. % in each chapter, section, etc.
  43. \def\refstepcounter#1{%
  44. \H@refstepcounter{#1}%
  45. \edef\This@name{#1}%
  46. \ifx\This@name\name@of@slide
  47. \else
  48. \if@skiphyperref
  49. \else
  50. \if@hyper@item
  51. \stepcounter{Item}%
  52. \hyper@refstepcounter{Item}%
  53. \else
  54. % \hyper@refstepcounter is only performed when it is neither a part,
  55. % nor a chapter/annex; the \hyper@refstepcounter is done
  56. % in the hook of thloria with \hyper@refstepcounter{division}.
  57. \def\@countername{#1}%
  58. \ifx\@countername\@partcountername
  59. \else
  60. \ifx\@countername\@chaptercountername
  61. \else
  62. \ifx\@countername\@annexcountername
  63. \else
  64. \hyper@refstepcounter{#1}%
  65. \fi
  66. \fi
  67. \fi
  68. \fi
  69. \fi
  70. \fi
  71. }
  72. % We add \hyper@refstepcounter{division} to the division counter hook
  73. \let\@old@division@inc@hook\@division@inc@hook
  74. \renewcommand{\@division@inc@hook}{%
  75. \@old@division@inc@hook
  76. \hyper@refstepcounter{division}
  77. }
  78. \newcommand\theHdivision {\arabic{division}}
  79. \renewcommand\theHfigure {\theHdivision.\arabic{figure}}
  80. \renewcommand\theHtable {\theHdivision.\arabic{table}}
  81. \renewcommand\theHsection {\theHdivision.\arabic{section}}
  82. % This boolean forces a bookmark to be at the topmost level;
  83. % it is only taken into account at the level of chapters (\chapter & \chapter*)
  84. % and it will thus act on the next \chapter(*).
  85. \newif\if@top@bookm@rk
  86. \@top@bookm@rkfalse
  87. \newcommand{\TLtopbookmark}{\@top@bookm@rktrue}
  88. % We input the file \jobname.flg in order to get the value of
  89. % `@there@were@p@rts':
  90. \InputIfFileExists{\jobname.flg}{}{}%
  91. % Numerical equivalent of `@there@were@p@rts':
  92. \if@there@were@p@rts
  93. \newcommand{\TL@topbookmarkpos}{-1}
  94. \else
  95. \newcommand{\TL@topbookmarkpos}{0}
  96. \fi
  97. \newcommand{\TL@bookmarkpos}{0}
  98. % needed by \addcontentsline :
  99. \newcommand{\toclevel@tlstarchapter}{0}
  100. \newcommand{\toclevel@starpart}{-1}
  101. \newcommand{\toclevel@spsection}{\TL@topbookmarkpos}
  102. % Changes of various hooks in thloria:
  103. \renewcommand{\@tlann@hook}[1]{%
  104. \@division@inc@hook
  105. \if@top@bookm@rk
  106. \renewcommand{\toclevel@tlstarchapter}{\TL@topbookmarkpos}
  107. \fi
  108. }
  109. \renewcommand{\@tlann@lasthook}[1]{\renewcommand{\toclevel@tlstarchapter}{0}}
  110. \renewcommand\@generic@schapter@hook[2]{%
  111. \if@top@bookm@rk
  112. \renewcommand{\toclevel@tlstarchapter}{\TL@topbookmarkpos}%
  113. \fi
  114. }
  115. \renewcommand\@generic@schapter@lasthook[2]{%
  116. \renewcommand{\toclevel@tlstarchapter}{0}%
  117. }
  118. \renewcommand\@generic@chapter@hook[3]{%
  119. \@generic@schapter@hook{#1}{#2}%
  120. }
  121. \renewcommand\@generic@chapter@lasthook[3]{%
  122. \@generic@schapter@lasthook{#1}{#2}%
  123. }
  124. \renewcommand{\@acknowledgment@hook}{%
  125. \@division@inc@hook
  126. \pdfbookmark[\TL@topbookmarkpos]{\AcknowledgmentName}%
  127. {acknowledgment.\theHdivision}%
  128. }
  129. \newcommand{\DedicationName}{D\'edicace}
  130. \renewcommand{\@dedication@hook}{%
  131. \@division@inc@hook
  132. \pdfbookmark[\TL@topbookmarkpos]{\DedicationName}{dedication.\theHdivision}%
  133. }
  134. \renewcommand{\@abstract@hook}[1]{%
  135. \@division@inc@hook
  136. \pdfbookmark[\TL@topbookmarkpos]{#1}{abstract.\theHdivision}%
  137. }
  138. \newcommand{\CoverName}{Couverture}
  139. \renewcommand{\@cover@hook}{%
  140. \@division@inc@hook
  141. \pdfbookmark[\TL@topbookmarkpos]{\CoverName}{cover.\theHdivision}%
  142. }
  143. \renewcommand{\@toc@hook}{%
  144. \pdfbookmark[\TL@topbookmarkpos]{\contentsname}{}%
  145. }
  146. \endinput
  147. % end of file tlhypref.sty