2 %% LaTeX style to handle hyperlatex files, version 2.8
4 %% This code has GNU copyleft, 1994-2000 Otfried Cheong
6 \NeedsTeXFormat{LaTeX2e}
8 \ProvidesPackage{hyperlatex}
9 [2004/11/12 v2.8 LaTeX2e package for Hyperlatex mode]
11 \typeout{Package: 'hyperlatex' v2.7 Otfried Cheong}
13 \RequirePackage{verbatim}
19 {\obeylines\gdef\Hlx@W#1^^M{\endgroup\ignorespaces}}
20 \def\W{\begingroup\obeylines\catcode`\{=\other\catcode`\}=\other\Hlx@W}
22 \newcommand{\htmlonly}[1]{}
23 \newcommand{\texorhtml}[2]{#1}
24 \newenvironment{iftex}{}{}
25 \newenvironment{latexonly}{}{}
26 \newcommand{\texonly}[1]{#1}
30 %% Treatment of special characters
33 \def\Hlx@nonspecials{}
34 \def\NotSpecial{\def\Hlx@nonspecials}
35 \def\Hlx@turnon{\let\do=\@makeother\Hlx@nonspecials}
36 \AtBeginDocument{\Hlx@turnon}
41 %% \begin{tex} ... \end{tex} escapes into raw Tex temporarily.
42 %% you can write {\tex .....} as well, if already escaped from Html
44 \newenvironment{tex}{\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
45 \catcode `\^=7 \catcode `\_=8 \catcode `\%=14}{}
51 \newcommand{\back}{{\tt\char`\\}}
57 \def\math{\@ifnextchar [{\@math}{\@math[]}}
58 \def\@math[#1]{\begingroup\tex\@@math}
59 \def\@@math#1{$#1$\endgroup}
62 %% Commands that don't do anything interesting in Latex
65 \def\Hlx@pass{\begingroup\let\protect\@unexpandable@noexpand\@sanitize}
69 %-- Never allow \Hlx@directory to be empty. See \endimage.
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}
82 \newcommand{\xmlsym}[1]{}
83 \newcommand{\htmlrule}{}
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]{}
95 \newcommand{\htmlimg}[2]{}
97 \newcommand{\xname}{\Hlx@pass\Hlx@ignore}
98 \def\Hlx@ignore#1{\endgroup}
100 \newcommand{\htmlpanel}[1]{}
101 \newcommand{\htmlheading}{\@ifnextchar[{\@htmlheading}{\@htmlheading[]}}
102 \def\@htmlheading[#1]#2{}
104 \newcommand{\htmlcaption}[1]{}
106 \def\xmlattributes{\@ifstar{\@xmlattributes}{\@xmlattributes}}
107 \def\@xmlattributes{\Hlx@pass\@@xmlattributes}
108 \def\@@xmlattributes#1#2{\endgroup}
109 \let\htmlattributes\xmlattributes
112 %% Image environment,
113 %% will generate bitmaps when `\makeimages' is defined
114 %% `\imagetype' will determine the type of images
116 \def\imagetype#1{\def\@imagetype{#1}}
118 \@ifundefined{@imagetype}{\def\@imagetype{png}}{}
121 \@ifundefined{makeimages}{\@makeimagesfalse}{\@makeimagestrue}
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}
129 \typeout{******************************************}
130 \typeout{* Making bitmaps from Hyperlatex source! *}
131 \typeout{******************************************}
132 \newwrite\@makeimagecmds
133 \immediate\openout\@makeimagecmds=\jobname.makeimage
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}
155 \def\gif{\imagetype{gif}\image}
156 \def\endgif{\endimage}
159 %% Font style definitions
172 %% \begin{example} ... \end{example} obeys spaces and lines
174 \def\Hlx@example{\do\$\do\&\do\#\do\^\do\_\do\~}
176 \gdef\turnon@spaces{\let =\ \obeyspaces\catcode``=\active\@noligs}}
178 \gdef\turnon@lines{\obeylines\def^^M{\par\def^^M{\leavevmode\par}}}}
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
186 %% font problem: math in example environment seems to need this:
188 \DeclareFontFamily{OMS}{cmtt}{}
189 \DeclareFontShape{OMS}{cmtt}{m}{n}{ <-> ssub * cmsy/m/n }{}
191 \newenvironment{menu}{\list{$\bullet$}{\itemsep0pt\parsep0pt}}{\endlist}
192 \newenvironment{ifhtml}{\comment}{\endcomment}
193 \newenvironment{rawxml}{\comment}{\endcomment}
197 \newcommand{\Hlx@empty}{}
198 \newcommand{\Hlx@zero}{0}
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}}
206 \def\ifclear#1{\Hlx@setclear{#1}
209 \let\endifset\endcomment\let\Hlx@comment\comment
211 %% arg false -> ignore begin and end
212 \let\endifset\relax\let\Hlx@comment\relax
215 \def\ifset#1{\Hlx@setclear{#1}
217 % arg true -> ignore begin and end
218 \let\endifclear\relax\let\Hlx@comment\relax
220 % arg false -> skip environment
221 \let\endifclear\endcomment\let\Hlx@comment\comment
225 %% Define \link and \xlink macros
227 \newcommand{\Hlx@label}{}
229 \newcommand{\Ref}{\ref{\Hlx@label}}
230 \newcommand{\Pageref}{\pageref{\Hlx@label}}
231 \newcommand{\Cite}{\cite{\Hlx@label}}
233 \newenvironment{Label}[1]{\def\Hlx@Label@label{\label{#1}}\ignorespaces}%
234 {\Hlx@Label@label\ignorespaces}
236 \newcommand{\htmlcite}[1]{\cite{#1}}
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
243 \def\@link[#1]#2{\gdef\Hlx@label{#2}#1}
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}
253 % index from latex.tex, and changed to include optional argument
255 \def\cindex{\@bsphack\begingroup
256 \let\protect\@unexpandable@noexpand
258 \@ifnextchar [{\Hlx@argwrindex}% balance ]
260 \def\Hlx@argwrindex[#1]#2{\@wrindex{#1@#2}}
262 %% end of hyperlatex.sty