%% demo.htx - this is an *HtX* file %% author: Richard Salter %% date: 5/23/97 %% This file demonstrates some of the features of the mmcc style \documentstyle{mmcc} \me{rms@cs.oberlin.edu} \lib[ffffff]{demovcbl}{Vocabulary} \returnto{../htx/index.html} \wallpaint{ffaabb} \begin{document} \docheader{HtX Demos}{1: Features of the mmcc Style} \begin{goallist} \item To demonstrate mmcc style features. \item To serve as a model. \end{goallist} \begin{prereqs} \item None \end{prereqs} {\bf\large To fully understand this document, you must have the HtX source. Compare the various features described below with their implementations in the HtX source.} \indx[link to source]{source} To view the source, click \xlink{demo.htx}{Here} \robinsEggBlue \section*{Some \latex-like features} \indx[.. and

tag]{HTML} It is a design goal of \htx\ to be as compatable as possible with \latex. Note that, as with \latex, line breaks are usually meaningless (except in verbatim environments). Double-line breaks produce the HTML

tag. Now, if you look at the HtX source, you find that you can use < and > without worry .. HtX takes care of turning them into entities. \indx[ .. and \latex-like features]{source} Other obvious correspondences are {\it italics\/} and {\bf bold-face} commands (using \verb/\bf/ and \verb/\it/; see the HtX source. \subsection*{Itemize-Enumerate-Description} HtX maps the LaTeX itemize-enumerate-description list environments to HTML unordered lists, ordered lists and definition lists, respectively. We begin with the ``itemize'' environment. It's very much like what you find in LaTeX. \begin{itemize} \item This is item number 1, which is followed by: \item item number 2. \item Finally, we have the third item. \end{itemize} Similar to itemize, we have an ``enumerate'' environment: \begin{enumerate} \item one \item two \item buckle \item my shoe \end{enumerate} You can force lists using capital letters, etc. using an optional argument: \begin{enumerate}[A] \item This is item A, which is followed by: \item item number B. \item Finally, we have the third item (C). \end{enumerate} Also try using [a] and [I]. Finally, there is ``description'' (or definition): \begin{description} \item[\bf the first] number one \item[\bf the second] number two, and \item[\bf the third] number six \end{description} \subsection*{Tables} \indx[Tables section]{tables} HtX implements versions of LaTeX's tabular and array environments using Netscape tables: \begin{tabular}{lcr} left¢er&right\\ 1&2&3\\ \hline a&b&c\\ \end{tabular} Also try: \begin{tabular}{|l|c|r|} left¢er&right\\ 1&2&3\\ \hline a&b&c\\ \end{tabular} and (to specifiy cell size) \begin{tabular}[10]{|l|c|r|} left¢er&right\\ 1&2&3\\ \hline a&b&c\\ \end{tabular} The array environment is similar for math displays \subsection*{Headers-fonts-alignment} We can put in headlines: \header{3}{Hello} in various sizes: \header{2}{Hello Again} and center them if need be: \begin{center} \header{1}{And Hello Again} \end{center} \centerline{You also can center this way} {\centering and this way} \indx[Font section]{fonts} HtX implements a \verb/\font/ command to change the fontsize. You {\font{+1} can {\font{+1} grow} or} {\font{-1} shrink} {\font{-2} relative} to the current font {\font{5} or specify an absolute font size}. We can {\em italicize} and {\bf bold-face} and {\tt typewriter-font} our text. Soon, math mode will be available. In the meantime we have some limited math mode commands: Inline: $T(n) = T(\frac{n}{2}) + T(\frac{n}{2}) + a$; or in displays: $$ T(n) = T(\frac{n}{2}) + T(\frac{n}{2}) + a\break T(1) = b $$ or: $$\begin{array}{lll} T(n)&=&T(2^{m})\\ &=&U(m)\\ &=&O(m log(m))\\ &=&O(log(n) (log (log (n))))\\ \end{array}$$ To engage a typewriter font, as we often do for including sections of program code, we can use the ``code'' environment. It switches to a fixed-width font and produces HTML that respects the layout of the HtX file. \begin{code} (define i-am-a-program-sample (lambda (x y) (cond ((= x y) 'now-i-stop) ((or (not (integer x)) (not (integer y))) (display "This program works with two integers") (newline)) ((> x y) (display "x is too big") (newline) (i-am-a-program-sample x (+ 1 y))) ((< x y) (display "x is too small") (newline) (i-am-a-program-sample (+ 1 x) y))))) \end{code} You can also enter a similar environment ``in-line'' with {\code (i-am-a-program-sample 2 8)}. \paleGreen \section{Some neat HTML paradigms} \subsection{The gloss* (i.e. footnote) environment} \indx[Glossary/footnotes]{glossary} Sometimes it's handy \begin{gloss*}{to jump elsewhere} for a little while. Of course, you can always return to the main window. This feature is useful, for example, for footnotes or for linking to an external program file. \end{gloss*} . If you do not follow the link to the footnote, you can just keep reading. \subsection{Reference citations} \indx[Reference section]{references} References may be listed at the end of the source file and cited from within: \cite{Baase}{Baase}. \indx[.. and citations]{source} (See the {\it refentry} entries at the end of the source file). Alternatively, a master bibliography can be referenced (analogous to BibTeX). See the Reference Guide for details. \subsection{Indexing} \indx{indexing} \indx[.. and indexing]{source} Indexing is easy: wrap the word you want to index, such as ``indexing'', inside the \verb/\indx/ command, just as I've done in the source. The \verb/\indx/ command produces no output, but enters the keyword into the index with a link to this location. At the very end of the file, include the command \verb/\doindex/. That's all there is to it! You will have an index section at the end of document, with links to each term you flag with \verb/\indx/. For this document I've included several indexed terms. \indx[.. and ``hot text'']{indexing} This example also shows how you can specify your own ``hot text'' to go in the indexing section, rather than using the default icon. For example, look in the index under ``indexing'', and you'll find a reference to this page. The hot text used for the link is the optional argument to \verb/\indx/. When you don't specify hot text you get a standard icon. \paleLavender \section{Courseware-specific environments} \subsection*{Questions and answers} \indx[Q \& A Section]{question and answer} \begin{quest} Do you know what a ``quest'' environment is? \ans Well this is one \end{quest} That was a straightforward question with an answer. What if you want to provide a hint? \begin{quest} May I have a hint please? \begin{hint}{A hint for you} Here is your hint \end{hint} \ans We hope the hint was useful \end{quest} That demonstrates HtX's question-hint-answer environment. There is also a multiple-choice question environment, implemented using a Java applet. \begin{mcquest} Do you know how to do a multiple choice question? \mans{No.} But inquiring minds should want to know. \mans{Yes.} Well, then you're smarter than you look. \mans{I don't care.} Go on to the next section then. \mans*{No, but I know where to look!} Right -- check out the HtX source. \mans{Whatever happened to blackboards and chalk?} Chalk dust fouls up the computers. \end{mcquest} \subsection*{Exercises} \indx[Exercise section]{exercises} At Oberlin, we use also use an ``exercise'' environment, which is used to assign work that is to be handed in. \begin{exercise}[Exercise titles appear in the table of contents] Write a program to determine if an arbitrary program, started with no input, will ever print the string ``Turing''. \end{exercise} \begin{exsol} You may include the solution in the htx file. Setting \verb/\solutionon/ in the preamble and retranslating will allow solutions to appear in the output. Otherwise they are flushed into the null device (On Unix systems: /dev/null) \end{exsol} \indx[.. and Exercises]{source} Exercises are automatically numbered. They are also catalogued in the table of contents that HtX automatically generates. Be sure to check the HtX source to see how exercise solutions can be included in the document. \begin{exercise}[Exercises are also numbered consecutively] Who was the first president of the United States? \begin{hint}{Exercise hint} His/her last name was the first name of Rip van Winkle's creator. \end{hint} \end{exercise} \section{Other HTML features} \subsection{Images} \indx[images]{HTML} All you need to do is to reference a .gif image: Images used only by one document may reside in the document's directory: \image[top]{foo.gif} See the \xlink{http://www.cs.oberlin.edu/htx/usrgd/ugd3xx4.html#rf@image} {entry} for {\it image\/} in the Htx Users guide to learn all the options. \subsection{Linking to other documents} The linking facility is provided by the ``xlink'' command. Here, for example is how to link to the HtX source for this document: \indx[link to source]{source} Click \xlink{demo.htx}{here} to see the source file for this suite of documents. \indx[link to home page]{HtX} Click \xlink{http://www.cs.oberlin.edu/htx/}{here} to see the HtX home page. \section{Some MMCC-specific features} \subsection{HTML display} \indx[HTML-display]{HTML} Using \htx\ to talk about HTML is a challenge. I've made a first attempt at an environment that will help with this, based on Mark Leone's suggestions. It is called the {\it html-display} environment: it first displays HTML markups in place, then provides a button to an ancillary file containing the markups that will display as intended. Here is an example: \begin{html-display}

\end{html-display} One problem is obvious: the HTML display loses its format. I will fix this, but it will take some tinkering with the HtX engine itself. \subsection{Automated Vocabulary} The automated vocabulary system makes use of \htx's library system to create document specific vocabulary lists drawn from a master vocabulary list (called a {\it lib\/} file). Here is what you do: \begin{enumerate} \item include in the preamble a command like: \begin{verbatim} \lib[ffffff]{demovcbl}{Vocabulary} \end{verbatim} {\tt demovcbl.lib} is the file containing your vocabulary definitions. The file has the form: \begin{verbatim} \lstart \lentry[title]{keyword} definition \lentry[title]{keyword} definition ... \lend \end{verbatim} \indx[in vocabulary]{keyword} {\tt title} represents the term being definied. {\tt keyword} is used to connect to the term from the text. It should be a single, lowercase word. If {\tt title} is omitted, it is the same as {\tt keyword}. Note: the final vocabulary list will be sorted by keyword. \xlink{demovcbl.lib}{Here} is a link to the lib file used for this demo. \item In your text you can annotate certain words using \verb/\vref/. For example: \begin{verbatim} All good \vref[wproc]{Word Processing} systems are \vref{WYSIWYG}. \end{verbatim} The result is: All good \vref[wproc]{Word Processing} systems are \vref{WYSIWYG}. Again, if the keyword is omitted, it is the same as the printed test. \item Include the command \verb/\vocab/ near the end of your document, just before any references. This will create the vocabulary section in the contents. \end{enumerate} Note: the simple \verb/\begin{vocab}..\end{vocab}/ construction has also been retained. Here are some more examples: \begin{quote} There are often 2 types of checkers in a \vref[wproc]{word processing} system: the \vref[spell]{spelling checker} checks spelling; the \vref[grammar]{grammar checker} checks grammar. Many systems also have capacity for \vref{headers} and \vref[headers]{footers}. Some do \vref[wordwrap]{word wrap} and \vref{justification}. \vref[font]{Font} sizes are in \vref{point}s or \vref{PICA} units. \end{quote} Note the \image{\icondir smenaw.gif} -- this reference does not have a corresponding entry in the lib file. Better put one in!! \vocab \doindex % ---references--- \refstart \refentry{Baase} Baase, S. {\it Computer Algorithms}, Reading: Addison-Wesley, 1993. \refentry{Cormen} Cormen, T. H., et al. {\it Introduction to Algorithms}, Cambridge: MIT Press, 1990. \refend \end{document}