Debian Codegraph @

texmf-dist/tex/latex/memoir/memhfixc.sty

raw
1 %%
2 %% This is file `memhfixc.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% mempatch.dtx (with options: `hyper')
8 %%
9 %% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
10 %% Copyright 2001 --- 2010 Peter R. Wilson
11 %% Copyright 2011 --- 2013 Peter R. Wilson
12 %% Copyright 2013 --- Lars Madsen
13 %% Maintainer: Lars Madsen (daleif at math dot au dot dk)
14 %%
15 %% This work may be distributed and/or modified under the
16 %% conditions of the LaTeX Project Public License, either
17 %% version 1.3 of this license or (at your option) any
18 %% later version.
19 %% The latest version of the license is in
20 %% http://www.latex-project.org/lppl.txt
21 %% and version 1.3 or later is part of all distributions of
22 %% LaTeX version 2003/06/01 or later.
23 %%
24 %% This work has the LPPL maintenance status "maintained".
25 %%
26 %% This work consists of the files listed in the README file.
27 %%
28 %%
29 %% The memhfixc package provides hyperref related temporary
30 %% fixes and extensions for the memoir class.
31 %% o hyperref fix for part and chapter entries in the ToC (v1.0)
32 %% o Other fixes as and when
33 %%
34 %% Only use this package in conjunction with the hyperref package.
35 %% Memoir will automatically load the package after hyperref, no
36 %% interaction needed
37 %%
38 %% Version 1.24 2025/09/16
39 %% Version 1.23 2025/03/06
40 %% Version 1.22 2023/09/10
41 %% Version 1.21 2023/07/28
42 %% Version 1.21 2023/07/28
43 %% Version 1.20 2022/11/17
44 %% Version 1.19 2021/06/16
45 %% Version 1.18 2019/10/24
46 %% Version 1.17 2013/05/30
47 %% Version 1.16 2013/05/16
48 %% Version 1.15 2010/08/17
49 %% Version 1.14 2010/06/10
50 %% Version 1.13 2010/04/19
51 %% Version 1.12 2009/02/06
52 %% Version 1.11 2009/01/18
53 %% Version 1.10 2008/08/23
54 %% Version 1.9 2006/11/22
55 %% Version 1.8 2006/01/21
56 %% Version 1.7 2005/11/15
57 %% Version 1.6 2004/05/13
58 %% Version 1.5 2003/10/14
59 %% Version 1.4 2003/09/26
60 %% Version 1.3 2003/02/20
61 %% Version 1.2 2003/02/02
62 %% Version 1.1 2003/01/22
63 %% Version 1.0 2002/10/22
64 %%
65 \ProvidesPackage{memhfixc}[2025/09/16 v1.24 hyperref package fixes for memoir class]
66 \let\M@hfixcfinish\relax
67 \@ifclassloaded{memoir}{}%
68 {\let\M@hfixcfinish\endinput
69 \typeout{No memoir class: memhfixc does nothing}}
70 \M@hfixcfinish
71
72 %% We are done unless the hyperref package has been loaded
73 \@ifpackageloaded{hyperref}{}{\let\M@hfixcfinish\endinput}
74 \M@hfixcfinish
75
76 \let\H@old@sbook\@sbook
77 \def\@sbook#1{%
78 \Hy@MakeCurrentHrefAuto{book*}%
79 \Hy@raisedlink{%
80 \hyper@anchorstart{\@currentHref}\hyper@anchorend
81 }%
82 \H@old@sbook{#1}
83 }
84
85 \ExplSyntaxOn
86 \cs_new_protected:Npn \_memoir_append_bookautorefname:nn #1#2
87 {
88 \@ifundefined{HyLang@#1}{}{%
89 \ExpandArgs{c}\g@addto@macro{HyLang@#1}{\def\bookautorefname{#2}}}
90 }
91 \clist_set:Nn \l_tmpa_clist {
92 {afrikaans}{Boek},
93 {english}{Book},
94 {french}{Livre},
95 {german}{Buch},
96 {italian}{Libro},
97 {magyar}{K\"onyv},
98 {portuges}{Livro},
99 {russian}{\CYRK\cyrn\cyri\cyrg\cyrr\cyra},
100 {spanish}{Libro},
101 {catalan}{Llibre},
102 {vietnamese}{T\d{\^{a}}p s\'{a}ch},
103 {greek}{\textBeta\textiota\textbeta\textlambda\'\textiota\textomicron},
104 {dutch}{Boek},
105 {norsk}{Bok},
106 {danish}{Bog},
107 {swedish}{Bok},
108 }
109 \clist_map_inline:Nn \l_tmpa_clist
110 { \_memoir_append_bookautorefname:nn #1 }
111 \ExplSyntaxOff
112
113 \providecommand{\bookautorefname}{Book}
114 \providecommand{\subfigureautorefname}{Subfigure}
115
116 \@ifundefined{H@old@sectm@m}{% haven't fiddled with \M@sect
117 \let\H@old@sectm@m\M@sect
118 \def\M@sect#1#2#3#4#5#6[#7][#8]#9{%
119 \ifnum #2>\c@secnumdepth%
120 \expandafter\@firstoftwo%
121 \else%
122 \expandafter\@secondoftwo%
123 \fi%
124 {%
125 \Hy@MakeCurrentHrefAuto{section*}%
126 \setlength{\Hy@SectionHShift}{#3}%
127 \begingroup
128 \toks@{\H@old@sectm@m{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#8}]}% <--
129 \toks\tw@\expandafter{%
130 \expandafter\Hy@SectionAnchorHref\expandafter{\@currentHref}%
131 #9% <---
132 }%
133 \edef\x{\endgroup%
134 \the\toks@{\the\toks\tw@}%
135 }\x%
136 }{%
137 \H@old@sectm@m{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#8}]{#9}% <--
138 }%
139 }%
140 }%
141 {% already fiddled \M@sect
142 }
143
144 \renewcommand{\cftaddtitleline}[4]{%
145 \addtocontents{#1}{\protect\contentsline{#2}{#3}{#4}{\@currentHref}}}
146 \renewcommand{\cftaddnumtitleline}[5]{\addtocontents{#1}{%
147 \protect\contentsline{#2}{\protect\numberline{#3}#4}{#5}{\@currentHref}}}
148
149 %\let\m@moldhypcaption\caption
150 %\renewcommand{\caption}{\donemaincaptiontrue\m@moldhypcaption}
151 \xpretocmd\caption{\donemaincaptiontrue}
152 {}{\typeout{Preto patch for \string\caption\space failed}}
153
154 \newcounter{memhycontfloat}
155 \renewcommand*{\thememhycontfloat}{\arabic{memhycontfloat}}
156 \providecommand*{\theHmemhycontfloat}{}
157 \renewcommand*{\theHmemhycontfloat}{\arabic{memhycontfloat}}
158 \setcounter{memhycontfloat}{0}
159
160 \renewcommand{\contcaption}{%
161 \par%
162 \refstepcounter{memhycontfloat}%
163 \addtocounter{\@captype}{\m@ne}\H@refstepcounter{\@captype}%
164 \@contcaption\@captype}
165
166 \renewcommand*\sidecaption@refstepcounter[2]{%
167 \H@refstepcounter{#1}%
168 \hyper@makecurrent{#2}%
169 }
170
171 % \def\endsidecaption{%
172 % \m@mscapend@fbox
173 % \H@refstepcounter{\@captype}%
174 % \hyper@makecurrent{\@captype}%
175 % \m@mscaplabel
176 % \m@mscapcheckside %<--- added 2013/05/30
177 % \begin{lrbox}{\m@mscap@capbox}%
178 % \begin{minipage}[c]{\sidecapwidth}%
179 % \sidecapstyle
180 % \@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}%
181 % \end{minipage}%
182 % \end{lrbox}%
183 % \m@mscapopboxes}
184
185 \renewcommand*{\sidecontcaption}{%
186 \refstepcounter{memhycontfloat}%
187 \@sidecontcaption}
188 % \def\endsidecontcaption{%
189 % \m@mscapend@fbox
190 % \addtocounter{\@captype}{\m@ne}\H@refstepcounter{\@captype}%
191 % \hyper@makecurrent{memhycontfloat}%
192 % \m@mscaplabel
193 % \m@mscapcheckside %<--- added 2013/05/30
194 % \begin{lrbox}{\m@mscap@capbox}%
195 % \begin{minipage}[c]{\sidecapwidth}%
196 % \sidecapstyle
197 % \@contcaption\@captype{\m@mscap@forcap}%
198 % \end{minipage}%
199 % \end{lrbox}%
200 % \m@mscapopboxes}
201
202 \AtBeginDocument{%
203 \let\printpageinnotes\printpageinnoteshyperref%
204 }
205 \ifHy@hyperfootnotes
206 \def\@footnotemark{%
207 \leavevmode
208 \ifhmode\edef\@x@sf{\the\spacefactor}%
209 \m@mmf@check% <--- added
210 \nobreak\fi
211 \stepcounter{Hfootnote}%
212 \global\let\Hy@saved@currentHref\@currentHref
213 \hyper@makecurrent{Hfootnote}%
214 \global\let\Hy@footnote@currentHref\@currentHref
215 \global\let\@currentHref\Hy@saved@currentHref
216 \hyper@linkstart{link}{\Hy@footnote@currentHref}%
217 \@makefnmark
218 \hyper@linkend
219 \m@mmf@prepare% <--- added
220 \ifhmode\spacefactor\@x@sf\fi
221 \relax
222 }%
223 \fi
224
225 \ifHy@hyperfootnotes
226 \let\m@m@pnwrite@fourtharg\m@m@pnwrite@fourtharg@hyperref
227 \let\pagenoteanchor\pagenotehyperanchor
228 \newcounter{mem@Hpagenote}
229 \@namedef{mem@pnmm@start@hook}{%
230 \stepcounter{mem@Hpagenote}%
231 \global\let\Hy@saved@currentHref\@currentHref
232 \hyper@makecurrent{mem@Hpagenote}%
233 \global\let\Hy@pagenote@currentHref\@currentHref
234 \global\let\@currentHref\Hy@saved@currentHref
235 \hyper@linkstart{link}{\Hy@pagenote@currentHref}%
236 }
237 \@namedef{mem@pnmm@end@hook}{\hyper@linkend}
238 \fi
239
240 \AtEndPackage{hypcap}{%
241 \long\def\@@contcaption##1##2{%
242 \par
243 \begingroup
244 \@parboxrestore
245 \if@minipage
246 \@setminipage
247 \fi
248 \global\@capstartfalse% added
249 \normalsize
250 \@makecaption{\csname fnum@##1\endcsname}{\ignorespaces ##2}\par
251 \endgroup}
252 }
253 \endinput
254 %%
255 %% End of file `memhfixc.sty'.