html.sty 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. % LaTeX2HTML Version 95.1 : html.sty
  2. %
  3. % WARNING: This file requires LaTeX2e. A LaTeX 2.09 version
  4. % is also provided, but with restricted functionality.
  5. %
  6. % This file contains definitions of LaTeX commands which are
  7. % processed in a special way by the translator.
  8. % For example, there are commands for embedding external hypertext links,
  9. % for cross-references between documents or for including
  10. % raw HTML.
  11. % This file includes the comments.sty file v2.0 by Victor Eijkhout
  12. % In most cases these commands do nothing when processed by LaTeX.
  13. % Modifications:
  14. %
  15. % nd = Nikos Drakos <[email protected]>
  16. % jz = Jelle van Zeijl <[email protected]>
  17. % hs = Herb Swan <[email protected]>
  18. % hs 31-JAN-96 - Added support for document segmentation
  19. % hs 10-OCT-95 - Added \htmlrule command
  20. % jz 22-APR-94 - Added support for htmlref
  21. % nd - Created
  22. %%%%MG added
  23. \NeedsTeXFormat{LaTeX2e}
  24. \ProvidesPackage{html}
  25. [1996/02/01 v1.0 hypertext commands for latex2html (nd, hs)]
  26. %%%%MG
  27. % Exit if the style file is already loaded
  28. % (suggested by Lee Shombert <[email protected]>
  29. \ifx \htmlstyloaded\relax \endinput\else\let\htmlstyloaded\relax\fi
  30. %%% LINKS TO EXTERNAL DOCUMENTS
  31. %
  32. % This can be used to provide links to arbitrary documents.
  33. % The first argumment should be the text that is going to be
  34. % highlighted and the second argument a URL.
  35. % The hyperlink will appear as a hyperlink in the HTML
  36. % document and as a footnote in the dvi or ps files.
  37. %
  38. \newcommand{\htmladdnormallinkfoot}[2]{#1\footnote{#2}}
  39. % This is an alternative definition of the command above which
  40. % will ignore the URL in the dvi or ps files.
  41. \newcommand{\htmladdnormallink}[2]{#1}
  42. % This command takes as argument a URL pointing to an image.
  43. % The image will be embedded in the HTML document but will
  44. % be ignored in the dvi and ps files.
  45. %
  46. \newcommand{\htmladdimg}[1]{}
  47. %%% CROSS-REFERENCES BETWEEN (LOCAL OR REMOTE) DOCUMENTS
  48. %
  49. % This can be used to refer to symbolic labels in other Latex
  50. % documents that have already been processed by the translator.
  51. % The arguments should be:
  52. % #1 : the URL to the directory containing the external document
  53. % #2 : the path to the labels.pl file of the external document.
  54. % If the external document lives on a remote machine then labels.pl
  55. % must be copied on the local machine.
  56. %
  57. %e.g. \externallabels{http://cbl.leeds.ac.uk/nikos/WWW/doc/tex2html/latex2html}
  58. % {/usr/cblelca/nikos/tmp/labels.pl}
  59. % The arguments are ignored in the dvi and ps files.
  60. %
  61. \newcommand{\externallabels}[2]{}
  62. %
  63. % This complements the \externallabels command above. The argument
  64. % should be a label defined in another latex document and will be
  65. % ignored in the dvi and ps files.
  66. %
  67. \newcommand{\externalref}[1]{}
  68. % This command adds a horizontal rule and is valid even within
  69. % a figure caption.
  70. %
  71. \newcommand{\htmlrule}{}
  72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  73. %
  74. % The following commands pertain to document segmentation, and
  75. % were added by Herbert Swan <[email protected]> (with help from
  76. % Michel Goossens <[email protected]>):
  77. %
  78. %
  79. % This command inputs internal latex2html tables so that large
  80. % documents can to partitioned into smaller (more manageable)
  81. % segments.
  82. %
  83. \newcommand{\internal}[2][internals]{}
  84. %
  85. % Define a dummy stub \htmlhead{}. This command causes latex2html
  86. % to define the title of the start of a new segment. It is not
  87. % normally placed in the user's document. Rather, it is passed to
  88. % latex2html via a .ptr file written by \segment.
  89. %
  90. \newcommand{\htmlhead}[2]{}
  91. %
  92. % The dummy command \endpreamble is needed by latex2html to
  93. % mark the end of the preamble in document segments that do
  94. % not contain a \begin{document}
  95. %
  96. \newcommand{\startdocument}{}
  97. %
  98. % Allocate a new set of section counters, which will get incremented
  99. % for "*" forms of sectioning commands, and for a few miscellaneous
  100. % commands.
  101. %
  102. \newcounter{lpart}
  103. \newcounter{lchapter}[part]
  104. \ifx\chapter\undefined\newcounter{lsection}[part]\else\newcounter{lsection}[chapter]\fi
  105. \newcounter{lsubsection}[section]
  106. \newcounter{lsubsubsection}[subsection]
  107. \newcounter{lparagraph}[subsubsection]
  108. \newcounter{lsubparagraph}[paragraph]
  109. \newcounter{lsubsubparagraph}[subparagraph]
  110. \newcounter{lequation}
  111. %
  112. % Redefine "*" forms of sectioning commands to increment their
  113. % respective counters.
  114. %
  115. \let\Hpart=\part
  116. \let\Hchapter=\chapter
  117. \let\Hsection=\section
  118. \let\Hsubsection=\subsection
  119. \let\Hsubsubsection=\subsubsection
  120. \let\Hparagraph=\paragraph
  121. \let\Hsubparagraph=\subparagraph
  122. \let\Hsubsubparagraph=\subsubparagraph
  123. %
  124. % The following definitions are specific to LaTeX2e:
  125. % (They must be commented out for LaTeX 2.09)
  126. %
  127. \def\part{\@ifstar{\stepcounter{lpart}\Hpart*}{\Hpart}}
  128. \def\chapter{\@ifstar{\stepcounter{lchapter}\Hchapter*}{\Hchapter}}
  129. \def\section{\@ifstar{\stepcounter{lsection}\Hsection*}{\Hsection}}
  130. \def\subsection{\@ifstar{\stepcounter{lsubsection}\Hsubsection*}{\Hsubsection}}
  131. \def\subsubsection{\@ifstar{\stepcounter{lsubsubsection}\Hsubsubsection*}{\Hsubsubsection}}
  132. \def\paragraph{\@ifstar{\stepcounter{lparagraph}\Hparagraph*}{\Hparagraph}}
  133. \def\subparagraph{\@ifstar{\stepcounter{lsubparagraph}\Hsubparagraph*}{\Hsubparagraph}}
  134. \def\subsubparagraph{\@ifstar{\stepcounter{lsubsubparagraph}\Hsubsubparagraph*}{\Hsubsubparagraph}}
  135. %
  136. % Define a helper macro to dump a single \secounter command to a file.
  137. %
  138. \newcommand{\DumpPtr}[2]{%
  139. \count255=\arabic{#1} \advance\count255 by \arabic{#2}
  140. \immediate\write\ptrfile{%
  141. \noexpand\setcounter{#1}{\number\count255}}}
  142. %
  143. % Define a helper macro to dump all counters to the file.
  144. % The value for each counter will be the sum of the l-counter
  145. % actual LaTeX section counter.
  146. % Also dump an \htmlhead{section-command}{section title} command
  147. % to the file.
  148. %
  149. \def\DumpCounters#1#2#3{\newwrite\ptrfile
  150. \immediate\openout\ptrfile = #1.ptr
  151. \DumpPtr{part}{lpart}
  152. \ifx\Hchapter\undefined\relax\else\DumpPtr{chapter}{lchapter}\fi
  153. \DumpPtr{section}{lsection}
  154. \DumpPtr{subsection}{lsubsection}
  155. \DumpPtr{subsubsection}{lsubsubsection}
  156. \DumpPtr{paragraph}{lparagraph}
  157. \DumpPtr{subparagraph}{lsubparagraph}
  158. \DumpPtr{equation}{lequation}
  159. \immediate\write\ptrfile{\noexpand\htmlhead{#2}{#3}}
  160. \immediate\closeout\ptrfile}
  161. %
  162. % Define the \segment{file}{section-command}{section-title} command,
  163. % and its helper macros. This command does four things:
  164. % 1) Begins a new LaTeX section;
  165. % 2) Writes a list of section counters to file.ptr, each
  166. % of which represents the sum of the LaTeX section
  167. % counters, and the l-counters, defined above;
  168. % 3) Write an \htmlhead{section-title} command to file.ptr;
  169. % 4) Inputs file.tex.
  170. %
  171. %%%%MG changed
  172. \def\segment{\@ifstar{\@@htmls}{\@@html}}
  173. \def\@@htmls#1#2#3{\csname #2\endcsname* {#3}%
  174. \DumpCounters{#1}{#2*}{#3}\input{#1}}
  175. \def\@@html#1#2#3{\csname #2\endcsname {#3}%
  176. \DumpCounters{#1}{#2}{#3}\input{#1}}
  177. %%%%MG
  178. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  179. % Comment.sty version 2.0, 19 June 1992
  180. % selectively in/exclude pieces of text: the user can define new
  181. % comment versions, and each is controlled separately.
  182. % This style can be used with plain TeX or LaTeX, and probably
  183. % most other packages too.
  184. %
  185. % Examples of use in LaTeX and TeX follow \endinput
  186. %
  187. % Author
  188. % Victor Eijkhout
  189. % Department of Computer Science
  190. % University Tennessee at Knoxville
  191. % 104 Ayres Hall
  192. % Knoxville, TN 37996
  193. % USA
  194. %
  195. % [email protected]
  196. %
  197. % Usage: all text included in between
  198. % \comment ... \endcomment
  199. % or \begin{comment} ... \end{comment}
  200. % is discarded. The closing command should appear on a line
  201. % of its own. No starting spaces, nothing after it.
  202. % This environment should work with arbitrary amounts
  203. % of comment.
  204. %
  205. % Other 'comment' environments are defined by
  206. % and are selected/deselected with
  207. % \includecomment{versiona}
  208. % \excludecoment{versionb}
  209. %
  210. % These environments are used as
  211. % \versiona ... \endversiona
  212. % or \begin{versiona} ... \end{versiona}
  213. % with the closing command again on a line of its own.
  214. %
  215. % Basic approach:
  216. % to comment something out, scoop up every line in verbatim mode
  217. % as macro argument, then throw it away.
  218. % For inclusions, both the opening and closing comands
  219. % are defined as noop
  220. %
  221. % Changed \next to \html@next to prevent clashes with other sty files
  222. % ([email protected])
  223. % Changed \html@next to \htmlnext so the \makeatletter and
  224. % \makeatother commands could be removed (they were causing other
  225. % style files - changebar.sty - to crash) ([email protected])
  226. % Changed \htmlnext back to \html@next...
  227. \makeatletter
  228. \def\makeinnocent#1{\catcode`#1=12 }
  229. \def\csarg#1#2{\expandafter#1\csname#2\endcsname}
  230. \def\ThrowAwayComment#1{\begingroup
  231. \def\CurrentComment{#1}%
  232. \let\do\makeinnocent \dospecials
  233. \makeinnocent\^^L% and whatever other special cases
  234. \endlinechar`\^^M \catcode`\^^M=12 \xComment}
  235. {\catcode`\^^M=12 \endlinechar=-1 %
  236. \gdef\xComment#1^^M{\def\test{#1}
  237. \csarg\ifx{PlainEnd\CurrentComment Test}\test
  238. \let\html@next\endgroup
  239. \else \csarg\ifx{LaLaEnd\CurrentComment Test}\test
  240. \edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
  241. \else \let\html@next\xComment
  242. \fi \fi \html@next}
  243. }
  244. \makeatother
  245. \def\includecomment
  246. #1{\expandafter\def\csname#1\endcsname{}%
  247. \expandafter\def\csname end#1\endcsname{}}
  248. \def\excludecomment
  249. #1{\expandafter\def\csname#1\endcsname{\ThrowAwayComment{#1}}%
  250. {\escapechar=-1\relax
  251. \csarg\xdef{PlainEnd#1Test}{\string\\end#1}%
  252. \csarg\xdef{LaLaEnd#1Test}{\string\\end\string\{#1\string\}}%
  253. }}
  254. \excludecomment{comment}
  255. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  256. %%% RAW HTML
  257. %
  258. % Enclose raw HTML between a \begin{rawhtml} and \end{rawhtml}.
  259. % The html environment ignores its body
  260. %
  261. \excludecomment{rawhtml}
  262. %%% HTML ONLY
  263. %
  264. % Enclose LaTeX constructs which will only appear in the
  265. % HTML output and will be ignored by LaTeX with
  266. % \begin{htmlonly} and \end{htmlonly}
  267. %
  268. \excludecomment{htmlonly}
  269. % Shorter version
  270. \newcommand{\html}[1]{}
  271. %%% LaTeX ONLY
  272. % Enclose LaTeX constructs which will only appear in the
  273. % DVI output and will be ignored by latex2html with
  274. %\begin{latexonly} and \end{latexonly}
  275. %
  276. \newenvironment{latexonly}{}{}
  277. % Shorter version
  278. \newcommand{\latex}[1]{#1}
  279. %%% HYPERREF
  280. % Suggested by Eric M. Carol <[email protected]>
  281. % Similar to \ref but accepts conditional text.
  282. % The first argument is HTML text which will become ``hyperized''
  283. % (underlined).
  284. % The second and third arguments are text which will appear only in the paper
  285. % version (DVI file), enclosing the fourth argument which is a reference to a label.
  286. %
  287. %e.g. \hyperref{using the tracer}{using the tracer (see Section}{)}{trace}
  288. % where there is a corresponding \label{trace}
  289. %
  290. \newcommand{\hyperref}[4]{#2\ref{#4}#3}
  291. %%% HTMLREF
  292. % Reference in HTML version only.
  293. % Mix between \htmladdnormallink and \hyperref.
  294. % First arg is text for in both versions, second is label for use in HTML
  295. % version.
  296. \newcommand{\htmlref}[2]{#1}
  297. %%% HTMLIMAGE
  298. % This command can be used inside any environment that is converted
  299. % into an inlined image (eg a "figure" environment) in order to change
  300. % the way the image will be translated. The argument of \htmlimage
  301. % is really a string of options separated by commas ie
  302. % [scale=<scale factor>],[external],[thumbnail=<reduction factor>
  303. % The scale option allows control over the size of the final image.
  304. % The ``external'' option will cause the image not to be inlined
  305. % (images are inlined by default). External images will be accessible
  306. % via a hypertext link.
  307. % The ``thumbnail'' option will cause a small inlined image to be
  308. % placed in the caption. The size of the thumbnail depends on the
  309. % reduction factor. The use of the ``thumbnail'' option implies
  310. % the ``external'' option.
  311. %
  312. % Example:
  313. % \htmlimage{scale=1.5,external,thumbnail=0.2}
  314. % will cause a small thumbnail image 1/5th of the original size to be
  315. % placed in the final document, pointing to an external image 1.5
  316. % times bigger than the original.
  317. %
  318. \newcommand{\htmlimage}[1]{}
  319. %%% HTMLADDTONAVIGATION
  320. % This command appends its argument to the buttons in the navigation
  321. % panel. It is ignored by LaTeX.
  322. %
  323. % Example:
  324. % \htmladdtonavigation{\htmladdnormallink
  325. % {\htmladdimg{http://server/path/to/gif}}
  326. % {http://server/path}}
  327. \newcommand{\htmladdtonavigation}[1]{}
  328. \endinput