fpc.sty 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \ProvidesPackage{fpc}[1996/12/09]
  22. \NeedsTeXFormat{LaTeX2e}
  23. \RequirePackage{multicol}
  24. \RequirePackage{epsfig}
  25. \RequirePackage{xspace}
  26. \RequirePackage{ifthen}
  27. \RequirePackage{listings}
  28. \RequirePackage{makeidx}
  29. \RequirePackage{a4}
  30. \RequirePackage{fancyhdr}
  31. \ExecuteOptions{titlepage}
  32. % Some style elements
  33. \parindent 0pt%
  34. \parskip 0.35\baselineskip%
  35. % First, all definitions for latex only.
  36. \newcommand{\docdescription}[1]{\def\@FPCDescription{#1}}
  37. \gdef\@FPCDescription{}%
  38. \newcommand{\docversion}[1]{\def\@FPCVersion{#1}}
  39. \gdef\@FPCVersion{}%
  40. % For backwards compatibility
  41. \newcommand{\unitdescription}[1]{\def\@FPCDescription{#1}}
  42. \newcommand{\unitversion}[1]{\def\@FPCVersion{#1}}
  43. \renewcommand\maketitle{\begin{titlepage}%
  44. \let\footnotesize\small
  45. \let\footnoterule\relax
  46. \null\vfil
  47. \vskip 4cm%
  48. {\noindent\raggedright\Large\@title\\}%
  49. \noindent \rule{\linewidth}{1.5mm}\\%
  50. {\raggedleft\large%
  51. \begin{tabular}[t]{r}%
  52. \@FPCDescription \\
  53. Document version \@FPCVersion \\
  54. \@date
  55. \end{tabular}\par}%
  56. \vskip 5cm%
  57. {\noindent \large \textsf{\@author} \\%
  58. \rule{\linewidth}{0.5mm}}
  59. \@thanks
  60. \vfil\null
  61. \end{titlepage}%
  62. \setcounter{footnote}{0}%
  63. \let\thanks\relax\let\maketitle\relax
  64. \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
  65. % end of \maketitle
  66. % For the \procedure and \function commands, we don't want heading numbers.
  67. \setcounter{secnumdepth}{1}
  68. % redefine the subsection command to leave less space,
  69. %and to use sans serif
  70. \renewcommand\subsection{\@startsection%
  71. {subsection}%
  72. {2}%
  73. {\z@}%
  74. {-4.25ex\@plus -1ex \@minus -.2ex}%
  75. {1pt}%
  76. {\normalfont\large\sffamily\bfseries}}
  77. % Now, Let's define the \procedure and \function commands.
  78. \newcommand{\FPClabel}[1]{%
  79. \raggedleft\makebox[0pt][r]{\textsf{#1:}}
  80. }
  81. %
  82. % FPC environments
  83. %
  84. % Lists
  85. \newenvironment{FPCList}
  86. {\begin{list}{}{%
  87. \renewcommand{\makelabel}[1]{\FPClabel{##1}\hfil\relax}
  88. \setlength{\labelwidth}{0pt}%
  89. \setlength{\leftmargin}{0pt}}%
  90. \setlength{\labelsep}{0pt}%
  91. }
  92. {\end{list}}
  93. %
  94. % remarks
  95. %
  96. \newenvironment{remark}{\par\makebox[0pt][r]{\bfseries{}Remark:\hspace{.25em}}}{\par}
  97. % For Tables.
  98. \newenvironment{FPCtable}[2]{\begin{table}[ht!]\caption{#2}\begin{center}\begin{tabular}{#1}}{\end{tabular}\end{center}\end{table}}
  99. % The same, but with label in third argument (tab:#3)
  100. \newenvironment{FPCltable}[3]{\begin{table}[ht]\caption{#2}\label{tab:#3}\begin{center}\begin{tabular}{#1}}{\end{tabular}\end{center}\end{table}}
  101. %
  102. % Refs
  103. %
  104. \newcommand{\seefig}[1]{figure (\ref{fig:#1})\xspace}
  105. \newcommand{\seefl}[2]{\textsf{#1} (\pageref{fu:#2})}
  106. \newcommand{\seepl}[2]{\textsf{#1} (\pageref{pro:#2})}
  107. \newcommand{\seetypel}[2]{\textsf{#1} (\pageref{ty:#2})}
  108. \newcommand{\seeconstl}[2]{\textsf{#1} (\pageref{co:#2})}
  109. \newcommand{\seevarl}[2]{\textsf{#1} (\pageref{var:#2})}
  110. \newcommand{\seec}[1]{chapter \ref{ch:#1}, page \pageref{ch:#1}\xspace}
  111. \newcommand{\sees}[1]{section \ref{se:#1}, page \pageref{se:#1}\xspace}
  112. \newcommand{\seeo}[1]{\var{-#1}, (see page \ref{option:#1})\xspace}
  113. \newcommand{\seet}[1]{table (\ref{tab:#1})\xspace}
  114. %
  115. % Function/procedure environments
  116. %
  117. \newenvironment{functionl}[2]{\subsection{#1}\index{#1}\label{fu:#2}\begin{FPCList}}{\end{FPCList}}
  118. \newenvironment{procedurel}[2]{\subsection{#1}\index{#1}\label{pro:#2}\begin{FPCList}}{\end{FPCList}}
  119. \newenvironment{method}[2]{\subsection{#1}\index{#1}\label{#2}\begin{FPCList}}{\end{FPCList}}
  120. \newenvironment{property}[2]{\subsection{#1}\index{#1}\label{#2}\begin{FPCList}}{\end{FPCList}}
  121. \newenvironment{function}[1]{\begin{functionl}{#1}{#1}}{\end{functionl}}
  122. \newenvironment{procedure}[1]{\begin{procedurel}{#1}{#1}}{\end{procedurel}}
  123. \newenvironment{typel}[2]{\subsection{#1}\index{#1}\label{ty:#2}\begin{FPCList}}{\end{FPCList}}
  124. \newenvironment{type}[1]{\begin{typel}{#1}{#1}}{\end{typel}}
  125. \newenvironment{constantl}[2]{\subsection{#1}\index{#1}\label{co:#2}\begin{FPCList}}{\end{FPCList}}
  126. \newenvironment{constant}[1]{\begin{constantl}{#1}{#1}}{\end{constantl}}
  127. \newenvironment{variablel}[2]{\subsection{#1}\index{#1}\label{var:#2}\begin{FPCList}}{\end{FPCList}}
  128. \newenvironment{variable}[1]{\begin{variablel}{#1}{#1}}{\end{variablel}}
  129. \newenvironment{ver2}{\par\textbf{version 2.0 only:}}{\par}
  130. \newcommand{\Declaration}{\item[Declaration]\ttfamily}
  131. \newcommand{\Description}{\item[Description]\rmfamily}
  132. \newcommand{\Portability}{\item[Portability]\rmfamily}
  133. \newcommand{\Errors}{\item[Errors]\rmfamily}
  134. \newcommand{\Visibility}{\item[Visibility]\rmfamily}
  135. \newcommand{\Access}{\item[Access]\rmfamily}
  136. \newcommand{\Synopsis}{\item[Synopsis]\rmfamily}
  137. \newcommand{\Arguments}{\item[Arguments]\rmfamily}
  138. \newcommand{\SeeAlso}{\item[See also]\rmfamily}
  139. %
  140. % Ref without labels
  141. %
  142. \newcommand{\seef}[1]{\seefl{#1}{#1}}
  143. \newcommand{\seep}[1]{\seepl{#1}{#1}}
  144. \newcommand{\seetype}[1]{\seetypel{#1}{#1}}
  145. \newcommand{\seevar}[1]{\seevarl{#1}{#1}}
  146. \newcommand{\seeconst}[1]{\seeconstl{#1}{#1}}
  147. %
  148. % man page references don't need labels.
  149. %
  150. \newcommand{\seem}[2]{\texttt{#1} (#2) }
  151. %
  152. % HTML references
  153. %
  154. \newcommand{\seeurl}[2]{\htmladdnormallink{#1}{#2}}
  155. %
  156. % for easy typesetting of variables.
  157. %
  158. \newcommand{\var}[1]{\texttt {#1}}
  159. \newcommand{\file}[1]{\textsf {#1}}
  160. \newcommand{\key}[1]{\textsc{#1}}
  161. \newcommand{\menu}[1]{\textbf{"#1"}}
  162. %
  163. % Useful references.
  164. %
  165. \newcommand{\progref}{\htmladdnormallink{Programmers guide}{../prog/prog.html}\xspace}
  166. \newcommand{\refref}{\htmladdnormallink{Reference guide}{../ref/ref.html}\xspace}
  167. \newcommand{\userref}{\htmladdnormallink{Users guide}{../user/user.html}\xspace}
  168. \newcommand{\unitsref}{\htmladdnormallink{Unit reference}{../units/units.html}\xspace}
  169. \newcommand{\seecrt}{\htmladdnormallink{CRT}{../crt/crt.html}\xspace}
  170. \newcommand{\seelinux}{\htmladdnormallink{Linux}{../linux/linux.html}\xspace}
  171. \newcommand{\seestrings}{\htmladdnormallink{strings}{../strings/strings.html}\xspace}
  172. \newcommand{\seedos}{\htmladdnormallink{DOS}{../dos/dos.html}\xspace}
  173. \newcommand{\seegetopts}{\htmladdnormallink{getopts}{../getopts/getopts.html}\xspace}
  174. \newcommand{\seeobjects}{\htmladdnormallink{objects}{../objects/objects.html}\xspace}
  175. \newcommand{\seegraph}{\htmladdnormallink{graph}{../graph/graph.html}\xspace}
  176. \newcommand{\seeprinter}{\htmladdnormallink{printer}{../printer/printer.html}\xspace}
  177. \newcommand{\seego}{\htmladdnormallink{GO32}{../go32/go32.html}\xspace}
  178. %
  179. % Commands to reference these things.
  180. %
  181. \newcommand{\olabel}[1]{\label{option:#1}}
  182. %
  183. % some OSes
  184. %
  185. \newcommand{\linux}{\textsc{linux}\xspace}
  186. \newcommand{\unix}{\textsc{unix}\xspace}
  187. \newcommand{\dos} {\textsc{dos}\xspace}
  188. \newcommand{\msdos}{\textsc{ms-dos}\xspace}
  189. \newcommand{\ostwo}{\textsc{os/2}\xspace}
  190. \newcommand{\windows}{\textsc{Windows}\xspace}
  191. \newcommand{\windowsnt}{\textsc{Windows NT}\xspace}
  192. \newcommand{\fpc}{Free Pascal\xspace}
  193. \newcommand{\gnu}{\textsc{gnu}\xspace}
  194. \newcommand{\atari}{\textsc{Atari}\xspace}
  195. \newcommand{\amiga}{\textsc{Amiga}\xspace}
  196. \newcommand{\solaris}{\textsc{Solaris}\xspace}
  197. \newcommand{\qnx}{\textsc{QNX Realtime platform}\xspace}
  198. \newcommand{\beos}{\textsc{BeOS}\xspace}
  199. \newcommand{\palmos}{\textsc{PalmOS}\xspace}
  200. \newcommand{\netbsd}{\textsc{NetBSD}\xspace}
  201. \newcommand{\openbsd}{\textsc{OpenBSD}\xspace}
  202. \newcommand{\win}{\textsc{Win32}\xspace}
  203. \newcommand{\freebsd}{\textsc{FreeBSD}\xspace}
  204. \newcommand{\tp}{Turbo Pascal\xspace}
  205. \newcommand{\delphi}{Delphi}
  206. %
  207. % Some versions
  208. %
  209. \newcommand{\fpcversion}{1.0.10}
  210. %
  211. % PDF support
  212. %
  213. \newif\ifpdf
  214. \ifx\pdfoutput\undefined
  215. \pdffalse
  216. \else
  217. \pdfoutput=1
  218. \pdftrue
  219. \fi
  220. %
  221. % PDF stuff
  222. %
  223. \ifpdf
  224. \usepackage[pdftex,bookmarks=true,colorlinks=true,linkcolor=blue]{hyperref}
  225. \usepackage{times}
  226. \usepackage[T1]{fontenc}
  227. \setcounter{secnumdepth}{1}
  228. \setcounter{tocdepth}{3}
  229. \pdfcompresslevel=9
  230. \pdfpagewidth=210mm
  231. \pdfpageheight=297mm
  232. \else
  233. \makeatletter
  234. \@ifpackageloaded{tex4ht}{%
  235. \usepackage[tex4ht,bookmarks=true,colorlinks=true,linkcolor=blue]{hyperref}
  236. }{%
  237. \usepackage[dvips,bookmarks=true,colorlinks=true,linkcolor=blue]{hyperref}
  238. }%
  239. \makeatother
  240. \fi
  241. %
  242. % Fake Latex2Html support, so latex2html is not required
  243. %
  244. \RequirePackage{fakehtml}
  245. %
  246. % For examples
  247. %
  248. \makeatletter
  249. \@ifpackageloaded{tex4ht}{%
  250. \newcommand{\FPCexample}[1]{
  251. \par \file{\textbf{Listing:} \exampledir/#1.pp}%
  252. \HCode{<HR/>}%
  253. \listinginput[9999]{5000}{\exampledir/#1.pp}%
  254. \HCode{<HR/>}%
  255. }%
  256. \newcommand{\Cexample}[1]{
  257. \par \file{\textbf{Listing:} \exampledir/#1.pp}%
  258. \listinginput[9999]{5000}{\exampledir/#1.c}%
  259. }
  260. }{% else ifpackageloaded
  261. \newcommand{\FPCexample}[1]{%
  262. \par \file{\textbf{Listing:} \exampledir/#1.pp}%
  263. \lstinputlisting{\exampledir/#1.pp}%
  264. }% End of FPCExample
  265. \newcommand{\Cexample}[1]{%
  266. \par \file{\textbf{Listing:} \exampledir/#1.c}%
  267. \lstinputlisting[language=c]{\exampledir/#1.c}%
  268. }% End of CExample
  269. }% End of ifpackageloaded.
  270. \makeatother
  271. \newcommand{\exampledir}{.}
  272. \newcommand{\FPCexampledir}[1]{\renewcommand{\exampledir}{#1}}
  273. %
  274. % Picture including
  275. %
  276. \newcommand{\FPCpic}[3]{%
  277. \begin{figure}[ht]%
  278. \begin{center}
  279. \caption{#1}%
  280. \label{fig:#3}%
  281. \ifpdf%
  282. \epsfig{file=pics/#2/#3.png,width=\textwidth}%
  283. \else%
  284. \epsfig{file=pics/#2/#3.eps,width=\textwidth}%
  285. \fi%
  286. \end{center}
  287. \end{figure}%
  288. }
  289. %
  290. % Categorical Function/procedure overviews
  291. %
  292. \newenvironment{funclist}{%
  293. \par
  294. \raisebox{-1em}{\makebox[\textwidth]{Name\hfill Description \hfill Page}}\\
  295. \rule{\textwidth}{1pt}
  296. \html{Name\hfill Description \hfill Page}
  297. \begin{list}{}{%
  298. \setlength{\rightmargin}{0pt}\setlength{\topsep}{0cm}\setlength{\partopsep}{0pt}%
  299. \setlength{\itemsep}{0pt}\setlength{\labelwidth}{3.5cm}%
  300. \setlength{\leftmargin}{4cm}%
  301. \renewcommand{\makelabel}[1]{\textsf{##1\hfil}}%
  302. }}%
  303. {\end{list}}
  304. \newcommand{\funcrefl}[3]{\item[#1] #3 \hfill\pageref{fu:#2}}
  305. \newcommand{\funcref}[2]{\item[#1] #2 \hfill\pageref{fu:#1}}
  306. \newcommand{\procrefl}[3]{\item[#1] #3 \hfill\pageref{pro:#2}}
  307. \newcommand{\procref}[2]{\item[#1] #2 \hfill\pageref{pro:#1}}
  308. %
  309. % Set some listings options.
  310. %
  311. \makeatletter
  312. \@ifpackageloaded{tex4ht}{%
  313. \usepackage{moreverb}
  314. }{%
  315. \usepackage{listings}%
  316. \lstset{language=Delphi}%
  317. \lstset{basicstyle=\sffamily\small}%
  318. \lstset{commentstyle=\itshape}%
  319. \lstset{keywordstyle=\bfseries}%
  320. \lstset{frame=tb}%
  321. \lstset{showstringspaces=false}%
  322. }
  323. \makeatother
  324. %
  325. % Page settings
  326. \setlength{\oddsidemargin}{20pt}
  327. \addtolength{\textwidth}{39pt}
  328. %
  329. % FancyHeader settings.
  330. %
  331. \pagestyle{fancy}
  332. \fancyhead[LO,RE]{}
  333. \addtolength{\headwidth}{\marginparsep}
  334. \addtolength{\headwidth}{\marginparwidth}
  335. \addtolength{\headwidth}{-59pt}
  336. %
  337. % end of fpc.sty