]> AND Private Git Repository - cours-maths-dis.git/blob - hyperlatex.sty
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
ajout de proposition13
[cours-maths-dis.git] / hyperlatex.sty
1 %%
2 %% LaTeX style to handle hyperlatex files, version 2.8
3 %%
4 %% This code has GNU copyleft, 1994-2000 Otfried Cheong
5 %%
6 \NeedsTeXFormat{LaTeX2e}
7
8 \ProvidesPackage{hyperlatex}
9 [2004/11/12 v2.8 LaTeX2e package for Hyperlatex mode]
10
11 \typeout{Package: 'hyperlatex' v2.7  Otfried Cheong}
12
13 \RequirePackage{verbatim}
14 \chardef\other=12
15
16 %%
17 %% Comments,
18 %%
19 {\obeylines\gdef\Hlx@W#1^^M{\endgroup\ignorespaces}}
20 \def\W{\begingroup\obeylines\catcode`\{=\other\catcode`\}=\other\Hlx@W}
21
22 \newcommand{\htmlonly}[1]{}
23 \newcommand{\texorhtml}[2]{#1}
24 \newenvironment{iftex}{}{}
25 \newenvironment{latexonly}{}{}
26 \newcommand{\texonly}[1]{#1}
27 \newcommand{\T}{}
28
29 %%
30 %% Treatment of special characters
31 %%
32
33 \def\Hlx@nonspecials{}
34 \def\NotSpecial{\def\Hlx@nonspecials}
35 \def\Hlx@turnon{\let\do=\@makeother\Hlx@nonspecials}
36 \AtBeginDocument{\Hlx@turnon}
37
38 \let\htmltab=&
39
40 %%
41 %% \begin{tex} ... \end{tex}    escapes into raw Tex temporarily.
42 %% you can write {\tex .....} as well, if already escaped from Html
43 %%
44 \newenvironment{tex}{\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
45 \catcode `\^=7 \catcode `\_=8 \catcode `\%=14}{}
46
47 %%
48 %% \back
49 %%
50
51 \newcommand{\back}{{\tt\char`\\}}
52
53 %%
54 %% \math
55 %%
56
57 \def\math{\@ifnextchar [{\@math}{\@math[]}}
58 \def\@math[#1]{\begingroup\tex\@@math}
59 \def\@@math#1{$#1$\endgroup}
60
61 %%
62 %% Commands that don't do anything interesting in Latex
63 %%
64
65 \def\Hlx@pass{\begingroup\let\protect\@unexpandable@noexpand\@sanitize}
66
67
68 \def\Hlx@directory{.}
69 %-- Never allow \Hlx@directory to be empty. See \endimage.
70
71 \newcommand{\htmldirectory}[1]{\gdef\Hlx@directory{#1}}
72 \newcommand{\htmlname}[1]{}
73 \newcommand{\htmldepth}[1]{}
74 \newcommand{\htmltopname}[1]{}
75 \newcounter{htmldepth}
76 \newcommand{\htmltitle}[1]{}
77 \newcommand{\htmladdress}[1]{}
78 \newcommand{\xml}{\Hlx@pass\@html}
79 \def\@html#1{\endgroup}
80 \let\html\xml
81
82 \newcommand{\xmlsym}[1]{}
83 \newcommand{\htmlrule}{}
84
85 \newcommand{\htmlmenu}[1]{}
86 \newcommand{\htmlautomenu}[1]{}
87 \newcounter{htmlautomenu}
88 \newcommand{\htmlprintindex}{}
89 \newcommand{\htmlfootnotes}{}
90 \newcommand{\htmlmathitalic}[1]{}
91 \newcommand{\htmlpanelfield}[2]{}
92 \newcommand{\htmlcharset}[1]{}
93 \newcommand{\htmlcss}[1]{}
94
95 \newcommand{\htmlimg}[2]{}
96
97 \newcommand{\xname}{\Hlx@pass\Hlx@ignore}
98 \def\Hlx@ignore#1{\endgroup}
99
100 \newcommand{\htmlpanel}[1]{}
101 \newcommand{\htmlheading}{\@ifnextchar[{\@htmlheading}{\@htmlheading[]}}
102 \def\@htmlheading[#1]#2{}
103
104 \newcommand{\htmlcaption}[1]{}
105
106 \def\xmlattributes{\@ifstar{\@xmlattributes}{\@xmlattributes}}
107 \def\@xmlattributes{\Hlx@pass\@@xmlattributes}
108 \def\@@xmlattributes#1#2{\endgroup}
109 \let\htmlattributes\xmlattributes
110
111 %%
112 %% Image environment,
113 %% will generate bitmaps when `\makeimages' is defined
114 %% `\imagetype' will determine the type of images
115
116 \def\imagetype#1{\def\@imagetype{#1}}
117
118 \@ifundefined{@imagetype}{\def\@imagetype{png}}{}
119
120 \newif\if@makeimages
121 \@ifundefined{makeimages}{\@makeimagesfalse}{\@makeimagestrue}
122
123 \def\image{\@ifnextchar[{\@image}{\@image[b]}}
124 \def\@image[#1]{\@ifnextchar[{\@@image}{\@@image[100]}}
125 \def\@@image[#1]{\gdef\image@resolution{#1}\@ifnextchar[{\@@@image}{\@@@image[300]}}
126 \def\@@@image[#1]#2{\gdef\image@dpi{#1}\gdef\image@name{#2}\@@@@image}
127
128 \if@makeimages
129 \typeout{******************************************}
130 \typeout{* Making bitmaps from Hyperlatex source! *}
131 \typeout{******************************************}
132 \newwrite\@makeimagecmds
133 \immediate\openout\@makeimagecmds=\jobname.makeimage
134 \newbox\@imagebox
135 \newdimen\@imageheight
136 \newcount\@imagecount\@imagecount=10000
137 \def\@@@@image{\setbox\@imagebox=\vbox\bgroup\tex}
138 \def\endimage{\egroup
139   {\global\advance\@imagecount by 1\count0=\@imagecount
140     \@imageheight=\ht\@imagebox
141     \advance\@imageheight by \dp\@imagebox
142     \immediate\write\@makeimagecmds{dvips\space -f\space -p\space
143       \the\@imagecount\space -n\space 1\space -D\space \image@dpi\space
144       -T\the\wd\@imagebox,\the\@imageheight\space-O-72bp,-72bp\space
145       \jobname.dvi\space>\space\image@name.ps^^J%
146       ps2image\space -res\space \image@resolution\space \image@name.ps%
147       \space \Hlx@directory/\image@name.\@imagetype^^J}
148     \shipout\copy\@imagebox}\unvbox\@imagebox}
149 \else
150 \def\@@@@image{\tex}
151 \def\endimage{}
152 \fi
153
154 %% For compatibility
155 \def\gif{\imagetype{gif}\image}
156 \def\endgif{\endimage}
157
158 %%
159 %% Font style definitions
160 %%
161
162 \let\cit=\textit
163 \let\code=\texttt
164 \let\kbd=\texttt
165 \let\samp=\texttt
166 \let\strong=\textbf
167 \let\var=\textsl
168 \let\dfn=\textit
169 \let\file=\textit
170
171 %%
172 %% \begin{example} ... \end{example} obeys spaces and lines
173 %%
174 \def\Hlx@example{\do\$\do\&\do\#\do\^\do\_\do\~}
175 {\obeyspaces
176   \gdef\turnon@spaces{\let =\ \obeyspaces\catcode``=\active\@noligs}}
177 {\obeylines%
178   \gdef\turnon@lines{\obeylines\def^^M{\par\def^^M{\leavevmode\par}}}}
179
180 \def\example{\list{}{\leftmargin\z@
181     \itemindent\z@ \rightmargin\z@ \parsep \z@ plus\p@}\item[]\tt
182   \turnon@spaces\turnon@lines\let\do\@makeother\Hlx@example}
183 \let\endexample=\endlist
184
185 %%
186 %% font problem:  math in example environment seems to need this:
187 %%
188 \DeclareFontFamily{OMS}{cmtt}{}
189 \DeclareFontShape{OMS}{cmtt}{m}{n}{ <-> ssub * cmsy/m/n }{}
190
191 \newenvironment{menu}{\list{$\bullet$}{\itemsep0pt\parsep0pt}}{\endlist}
192 \newenvironment{ifhtml}{\comment}{\endcomment}
193 \newenvironment{rawxml}{\comment}{\endcomment}
194
195 \def\xmlinclude#1{}
196
197 \newcommand{\Hlx@empty}{}
198 \newcommand{\Hlx@zero}{0}
199 \newif\if@Hlx
200
201 \def\Hlx@setclear#1{\@ifundefined{#1}{\@Hlxfalse}{%
202     \expandafter\ifx\csname#1\endcsname\Hlx@empty\@Hlxfalse
203     \else\expandafter\ifx\csname#1\endcsname\Hlx@zero\@Hlxfalse
204     \else\@Hlxtrue\fi\fi}}
205
206 \def\ifclear#1{\Hlx@setclear{#1}
207   \if@Hlx
208   %% arg true -> skip
209   \let\endifset\endcomment\let\Hlx@comment\comment
210   \else
211   %% arg false -> ignore begin and end
212   \let\endifset\relax\let\Hlx@comment\relax
213   \fi\Hlx@comment}
214
215 \def\ifset#1{\Hlx@setclear{#1}
216   \if@Hlx
217   % arg true -> ignore begin and end
218   \let\endifclear\relax\let\Hlx@comment\relax
219   \else
220   % arg false -> skip environment
221   \let\endifclear\endcomment\let\Hlx@comment\comment
222   \fi\Hlx@comment}
223
224 %%
225 %% Define \link and \xlink macros
226 %%
227 \newcommand{\Hlx@label}{}
228
229 \newcommand{\Ref}{\ref{\Hlx@label}}
230 \newcommand{\Pageref}{\pageref{\Hlx@label}}
231 \newcommand{\Cite}{\cite{\Hlx@label}}
232
233 \newenvironment{Label}[1]{\def\Hlx@Label@label{\label{#1}}\ignorespaces}%
234 {\Hlx@Label@label\ignorespaces}
235
236 \newcommand{\htmlcite}[1]{\cite{#1}}
237
238 \def\link{\@ifstar{\@star@link}{\@@link}}
239 \def\@@link#1{#1\@@@link}
240 \def\@star@link#1{\@@@link}
241 \def\@@@link{\@ifnextchar [{\@link}% ] balance
242   {\@link[]}}
243 \def\@link[#1]#2{\gdef\Hlx@label{#2}#1}
244
245 \def\xlink{\@ifstar{\@star@xlink}{\@@xlink}}
246 \def\@@xlink#1{\@@@xlink{#1}}
247 \def\@star@xlink#1{\@@@xlink{}}
248 \def\@@@xlink#1{\@ifnextchar [{\@xlink{#1}}{\@xlink{#1}[]}}
249 \def\@xlink#1[#2]#3{\formatxlink{#1#2}{#3}}
250 \newcommand{\formatxlink}[2]{#1}
251
252 %
253 % index from latex.tex, and changed to include optional argument
254 %
255 \def\cindex{\@bsphack\begingroup
256   \let\protect\@unexpandable@noexpand
257   \@sanitize
258   \@ifnextchar [{\Hlx@argwrindex}% balance ]
259   {\@wrindex}}
260 \def\Hlx@argwrindex[#1]#2{\@wrindex{#1@#2}}
261
262 %% end of hyperlatex.sty
263