Graphlet.sty 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. \ProvidesPackage{Graphlet}
  2. \RequirePackage{ifthen}
  3. \newboolean{Report}
  4. \setboolean{Report}{false}
  5. \DeclareOption{Report}{\setboolean{Report}{true}}
  6. \newboolean{Article}
  7. \setboolean{Article}{false}
  8. \DeclareOption{Article}{\setboolean{Article}{true}}
  9. \newboolean{Psfonts}
  10. \setboolean{Psfonts}{false}
  11. \DeclareOption{Psfonts}{\setboolean{Psfonts}{true}}
  12. \newboolean{Float}
  13. \setboolean{Float}{false}
  14. \DeclareOption{Float}{\setboolean{Float}{true}}
  15. \newboolean{Headings}
  16. \setboolean{Headings}{false}
  17. \DeclareOption{Headings}{\setboolean{Headings}{true}}
  18. \newboolean{Frames}
  19. \setboolean{Frames}{false}
  20. \DeclareOption{Frames}{\setboolean{Frames}{true}}
  21. \ProcessOptions
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. %
  24. % Customization
  25. %
  26. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. \ifthenelse{\boolean{Frames}}{%
  28. \newcommand{\Frame}[1]{\fbox{#1}}
  29. }{
  30. \newcommand{\Frame}[1]{#1}
  31. }
  32. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  33. %
  34. % Packages
  35. %
  36. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  37. %
  38. % Use alltt to include source code
  39. %
  40. \usepackage{alltt}
  41. %
  42. % Support Index
  43. %
  44. \usepackage{makeidx}
  45. %
  46. % ``float'' package for enhanced floats
  47. %
  48. %
  49. \ifthenelse{\boolean{Float}}%
  50. {
  51. \usepackage{float}
  52. \restylefloat{figure}
  53. \restylefloat{table}
  54. }{}
  55. %
  56. % extended tabular
  57. %
  58. \usepackage{array}
  59. %
  60. % Pagestyle
  61. %
  62. \ifthenelse{\boolean{Report}}%
  63. {
  64. \ifthenelse{\boolean{Headings}}{
  65. \RequirePackage{fancyheadings}
  66. \pagestyle{fancy}
  67. \renewcommand{\chaptermark}[1]{\markboth{#1}{}}
  68. \renewcommand{\sectionmark}[1]{\markright{#1}}
  69. \lhead%
  70. [\fancyplain{}{\rmfamily\bfseries \thepage\qquad\leftmark}]%
  71. {\fancyplain{}{\rmfamily\bfseries Section \thesection}}
  72. \chead{}
  73. \rhead%
  74. [\fancyplain{}{\rmfamily\bfseries Chapter \thechapter}]%
  75. {\fancyplain{}{\rmfamily\bfseries \rightmark\qquad\thepage}}
  76. \lfoot{}
  77. \cfoot%
  78. [\emph{Draft Version}]%
  79. {Graphlet Version \GraphletVersion}
  80. \rfoot{}
  81. }{}
  82. }{}
  83. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  84. %
  85. % Commands
  86. %
  87. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  88. %
  89. % \Param{x} should be used to indicate parameters of functions within
  90. % a tt-style text. \emph should be used in normal text.
  91. %
  92. % \ttcomment{c} is a commment in a text which is set in
  93. %
  94. % Both are needed to avoid a tt-style \emph.
  95. %
  96. \newcommand{\Param}[1]{\mbox{\textnormal{\emph{#1}}}}
  97. \newcommand{\ttcomment}[1]{\mbox{\textnormal{\emph{#1}}}}
  98. %
  99. % \GT{x} creates GT_x in typewriter font
  100. % \GTTcl{x} creates GT_Tcl_x in typewriter font
  101. % \gt{x} creates gt_x in typewriter font
  102. %
  103. \newcommand{\GT}[1]{\texttt{GT\_#1}}
  104. \newcommand{\GTTcl}[1]{\texttt{GT\_Tcl\_#1}}
  105. \newcommand{\gt}[1]{\texttt{gt\_#1}}
  106. %
  107. % Names (Compatibility only)
  108. %
  109. %\newcommand{\GraphScript}{GraphScript}
  110. %\newcommand{\Graphlet}{Graphlet}
  111. %\newcommand{\GML}{GML}
  112. %
  113. % Shortcuts
  114. % ---------
  115. %
  116. % \TDB ``To be done''
  117. % \ToDo ``To do''
  118. % \NYI ``Not Yet Implemented''
  119. %
  120. \newcommand{\TBD}{\emph{To be done}}
  121. \newcommand{\ToDo}{\emph{To Do}}
  122. \newcommand{\NYI}[1][foot]{%
  123. \ifthenelse{\equal{#1}{foot}}{%
  124. \footnote{Not yet implemented in Graphlet.}%
  125. }{%
  126. \emph{Not yet implemented in Graphlet.}%
  127. }%
  128. }
  129. \newcommand{\NYD}{\emph{Not yet documented.}}
  130. %
  131. % \Important
  132. %
  133. \newcommand{\Important}{\marginpar[$\Rightarrow$]{$\Leftarrow$}}
  134. %
  135. % Symbols
  136. %
  137. \newcommand{\Left}{\symbol{'133}}
  138. \newcommand{\Right}{\symbol{'135}}
  139. \newcommand{\Tilde}{\symbol{'176}}
  140. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  141. %
  142. %
  143. %
  144. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  145. \setcounter{secnumdepth}{3}
  146. \setcounter{tocdepth}{3}
  147. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  148. %
  149. % Graphlet Environments
  150. %
  151. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  152. %
  153. % Notes et al
  154. %
  155. \newenvironment{note}%
  156. {\begin{small}\textsc{Note:}}%
  157. {\end{small}}
  158. \newenvironment{interna}%
  159. {\begin{small}}%
  160. {\end{small}}
  161. \newenvironment{WhoNeedsThis}%
  162. {\marginpar{\emph{Who needs this section ?}}}%
  163. {}
  164. \newenvironment{WhoCanSkipThis}%
  165. {\marginpar{\emph{Who can skip this section ?}}}%
  166. {}
  167. \newcounter{notes}
  168. \newenvironment{notes}%
  169. {\begin{small}\begin{list}%
  170. {\textsc{Note} \arabic{notes}. }%
  171. {\usecounter{notes}%
  172. \setlength{\labelsep}{0pt}%
  173. \setlength{\labelwidth}{0pt}%
  174. \setlength{\leftmargin}{0pt}%
  175. \setlength{\listparindent}{0pt}%
  176. }%
  177. }%
  178. {\end{list}\end{small}}
  179. \newenvironment{Standard}{\strut\marginpar{\emph{Standard}}}{}
  180. %
  181. % Example
  182. %
  183. % \begin{example}{label}{caption}
  184. % .. here is the example ...
  185. % \end{example}
  186. \newenvironment{example}[3][htbp]%
  187. {%
  188. \begin{figure}[#1]
  189. \newcommand{\exampleRef}{#2}
  190. \newcommand{\exampleCaption}{#3}
  191. \hrule\hrule\hspace*{1ex}
  192. }%
  193. {%
  194. \hrule\hrule%
  195. \caption{\exampleCaption}%
  196. \label{\exampleRef}%
  197. \end{figure}%
  198. }
  199. %
  200. % Skills: describe what skills are needed for the current section.
  201. %
  202. \newenvironment{skills}[1][section]%
  203. {%
  204. Readers \Important{} of this #1 should have basic
  205. knowledge in the following topics:
  206. \begin{quote}
  207. }%
  208. {\end{quote}}
  209. %
  210. % Utilities to describe the location of source code and the include
  211. % files
  212. %
  213. \newcommand{\CIncludeStatement}[3]{%
  214. \begin{small}
  215. To\Important{} use #1 include the following in your C++ code:
  216. \begin{quote}
  217. \texttt{\#include $<$\gt{#2}/#3.h$>$}
  218. \end{quote}
  219. \end{small}
  220. }
  221. \newcommand{\CSourceCodeLocation}[3]{%
  222. \begin{small}
  223. The source code for #1 is in the files
  224. \begin{itemize}
  225. \item \texttt{src/gt\_#2/#3.h}
  226. \item \texttt{src/gt\_#2/#3.cpp}
  227. \end{itemize}
  228. \end{small}
  229. }
  230. \newcommand{\CSourceCode}[3]{%
  231. \CSourceCodeLocation%
  232. {\ifthenelse{\equal{#1}{}}{class \GT{#3}}{#1}}{#2}{#3}
  233. \CIncludeStatement%
  234. {\ifthenelse{\equal{#1}{}}{class \GT{#3}}{#1}}{#2}{#3}
  235. }
  236. \newcommand{\TclSourceCodeLocation}[2]{%
  237. \begin{small}
  238. The source code for #1 is in the file
  239. \begin{itemize}
  240. \item \texttt{lib/graphscript/#2.tcl}
  241. \end{itemize}
  242. \end{small}
  243. }
  244. %
  245. % List of defintitions
  246. %
  247. \newenvironment{ttdescription}%
  248. {\renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  249. \begin{description}}%
  250. {\end{description}}
  251. \newenvironment{Cdefinition}%
  252. {
  253. \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  254. \begin{description}
  255. \newcommand{\Hints}[2]{
  256. \ifthenelse{\equal{##1}{}}%
  257. {\strut\marginpar{\footnotesize \Frame{##2}}}
  258. {\strut\marginpar{\footnotesize \Frame{##2,##1}}}}
  259. }
  260. {\end{description}}
  261. \newenvironment{CAttributes}%
  262. {\renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  263. \begin{description}}%
  264. {\end{description}}
  265. %
  266. % Tcl commands, arguments etc.
  267. %
  268. %\newenvironment{TclArguments}[1]%
  269. %{
  270. % \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  271. % \begin{description}
  272. %}%
  273. %{
  274. % \end{description}
  275. %}
  276. \newenvironment{TclAttributes}[1]%
  277. {
  278. \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  279. \newcommand{\Entry}[3]{\item[##1] \te{##2} \hfill ##3\strut\\}
  280. \begin{ttdescription}
  281. }%
  282. {
  283. \end{ttdescription}
  284. }
  285. %\newenvironment{TclOptions}[2]%
  286. %{%
  287. % \begin{table}[htbp]
  288. % \newcommand{\TclOptionsRef}{#1}
  289. % \newcommand{\TclOptionsCaption}{#2}
  290. % \hrule\hrule\hspace*{1ex}
  291. % \begin{tabular}{>{\tt}p{0.3\textwidth}@{}p{0.6\textwidth}}
  292. %}%
  293. %{%
  294. % \end{tabular}
  295. % \hrule\hrule%
  296. % \caption{\TclOptionsCaption}%
  297. % \label{\TclOptionsRef}%
  298. % \end{table}%
  299. %}
  300. \newenvironment{TclOptions}%
  301. {%
  302. \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  303. \newcommand{\Entry}[2]{\item[##1]\te{##2}\strut\\}
  304. \newcommand{\Optional}[1]{?##1?}
  305. \begin{description}
  306. }%
  307. {%
  308. \end{description}
  309. }
  310. %\newenvironment{TclArray}[2]%
  311. %{%
  312. % \begin{table}[htbp]
  313. % \newcommand{\TclOptionsRef}{#1}
  314. % \newcommand{\TclOptionsCaption}{#2}
  315. % \newcommand{\Entry}[2]{##1 & ##2 \\}
  316. % \hrule\hrule\hspace*{1ex}
  317. % \begin{tabular}{>{\tt}p{0.3\textwidth}@{}p{0.6\textwidth}}
  318. %}%
  319. %{%
  320. % \end{tabular}
  321. % \hrule\hrule%
  322. % \caption{\TclOptionsCaption}%
  323. % \label{\TclOptionsRef}%
  324. % \end{table}%
  325. %}
  326. \newenvironment{TclArray}%
  327. {%
  328. \renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  329. \newcommand{\Entry}[1]{\item[##1]\strut\\}
  330. \begin{description}
  331. }%
  332. {%
  333. \end{description}
  334. }
  335. \newenvironment{Handlers}[1]%
  336. {%
  337. \texttt{#1}\marginpar{\Frame{\emph{Handlers}}} calls the following handlers~:
  338. \begin{itemize}
  339. }{%
  340. \end{itemize}
  341. }
  342. \newenvironment{Hooks}[1]%
  343. {%
  344. \texttt{#1}\marginpar{\Frame{\emph{Hooks}}} calls the following hooks~:
  345. \begin{itemize}
  346. }{%
  347. \end{itemize}
  348. }
  349. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  350. %
  351. % C/C++ declaration
  352. %
  353. % \begin{Cdeclaration}{Name}{LongName}
  354. % \end{Cdeclaration}
  355. %
  356. % The environment Cdeclaration should be used to include the listing of a
  357. % C/C++ declaration. Argument 1 is the name which is used in the label,
  358. % argument 2 is the long name as used in the caption.
  359. %
  360. % Example:
  361. %
  362. % \begin{Cdeclaration}{GTSamle}{class \GT{Samle}}
  363. % \end{Cdeclaration}
  364. %
  365. % The declaration of class \GT{Sample} is shown in
  366. % Figure \ref{Cdeclaration:GTSample}
  367. %
  368. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  369. \newenvironment{Cdeclaration}[2]%
  370. {%
  371. \begin{figure}[h]
  372. \newcommand{\CdeclarationName}{#1}
  373. \newcommand{\CdeclarationLongName}{#2}
  374. \hrule\hspace*{1ex}
  375. }%
  376. {%
  377. \hrule
  378. \caption{The declaration of \CdeclarationLongName.}
  379. \label{Cdeclaration:\CdeclarationName}
  380. \end{figure}
  381. }
  382. %
  383. % quote + tt + tabbing
  384. %
  385. \newenvironment{ttquote}%
  386. {\begin{quote}\begin{alltt}}%
  387. {\end{alltt}\end{quote}}
  388. %\Newenvironment{Qttt}%
  389. %{\Begin{Quote}
  390. % \Begin{Tt}\Begin{Tabbing}
  391. % \ \ \ \ \=\ \ \ \ \ \ \=\ \ \ \ \=\ \ \ \ \=\ \ \=\Kill
  392. % }%
  393. %{\End{Tabbing}\End{Tt}\End{Quote}}
  394. %
  395. % GML Definition
  396. %
  397. \newtheorem{definition}{Definition}
  398. \newenvironment{GMLAttributes}%
  399. {%
  400. %\renewcommand{\descriptionlabel}[1]{\hspace{\labelsep}\texttt{##1}}
  401. \begin{description}
  402. \newcommand{\GMLAttr}[4][safe]{%
  403. \item[\texttt{##2}]
  404. \ifthenelse{\equal{##3}{B}}{\emph{Boolean}}{%
  405. \ifthenelse{\equal{##3}{I}}{\emph{Integer}}{%
  406. \ifthenelse{\equal{##3}{L}}{\emph{List}}{%
  407. \ifthenelse{\equal{##3}{S}}{\emph{String}}{%
  408. \ifthenelse{\equal{##3}{R}}{\emph{Real}}{%
  409. \emph{##3}%
  410. }%
  411. }%
  412. }%
  413. }%
  414. }%
  415. \hfill
  416. \makebox[6cm][l]{\texttt{##4}}\qquad
  417. \ifthenelse{\equal{##1}{safe}}{\textbf{Safe}}{\textbf{Unsafe}}\\
  418. }
  419. }%
  420. {\end{description}}
  421. %
  422. % Definitions for easy BNF grammar descriptions
  423. %
  424. \newenvironment{bnf}[1]%
  425. {
  426. \newcommand{\Assign}{\=::=\=}
  427. \newcommand{\Choice}{\mbox{$\,\mid\,$}}
  428. \newcommand{\Newline}{\\\>\>}
  429. \newcommand{\Declare}[2]{\NonTerm{##1}\>::=\>##2\\[1.0ex]}
  430. % \newcommand{\NonTerm}[1]{\mbox{\emph{##1}}}
  431. % \newcommand{\Term}[1]{\mbox{\underline{\tt ##1}}}
  432. \newcommand{\NonTerm}[1]{$<$\emph{##1}$>$}
  433. \newcommand{\Term}[1]{`##1'}
  434. \newcommand{\ZeroOrMore}[1]{\mbox{##1$^*$}}
  435. \newcommand{\OneOrMore}[1]{\mbox{##1$^+$}}
  436. \newcommand{\ZeroOrOne}[1]{\mbox{##1$_{0}^{1}$}}
  437. \newcommand{\Range}[1]{$\left[\textnormal{##1}\right]$}
  438. \newcommand{\FromTo}[2]{\Term{##1}-\Term{##2}}
  439. \newcommand{\Alternative}[1]{\Choice{} ##1}
  440. \newcommand{\AlternativeLine}[1]{\Choice{}\Newline{}##1}
  441. \newcommand{\Empty}{\mbox{$\lambda$}}
  442. \newcommand{\Group}[1]{(##1)}
  443. \begin{tabbing}
  444. #1\quad\= ::=\quad\=\kill\\
  445. }
  446. {
  447. \end{tabbing}
  448. }
  449. \newenvironment{program}%
  450. {\begin{tabbing}
  451. \ \ \ \ \=\ \ \ \ \=\ \ \ \ \=\ \ \ \ \=\kill
  452. }{\end{tabbing}}
  453. \ifthenelse{\boolean{Psfonts}}%
  454. {
  455. \usepackage{pslatex}
  456. \renewcommand{\rmdefault}{phv}
  457. }{%
  458. }
  459. \newcommand{\te}[1]{\texttt{\emph{#1}}}
  460. \usepackage{shortvrb}
  461. \MakeShortVerb{\|}
  462. \newcommand{\Ref}[1]{\ref{#1}}
  463. %%% Local Variables:
  464. %%% mode: latex
  465. %%% End: