summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/eplain/demo
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-12-08 00:25:19 +0000
committerKarl Berry <karl@freefriends.org>2006-12-08 00:25:19 +0000
commit7ff51640e2fd3e968488d312879dee70458f2926 (patch)
tree6b9ede61598bd09a713892640d2d41da6913e509 /Master/texmf-dist/doc/eplain/demo
parent8291b74ec6f858e3536a5919b74386a7df1dcc24 (diff)
eplain 3.1 (5dec06)
git-svn-id: svn://tug.org/texlive/trunk@2630 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/eplain/demo')
-rw-r--r--Master/texmf-dist/doc/eplain/demo/Makefile41
-rw-r--r--Master/texmf-dist/doc/eplain/demo/lscommnt.tex47
-rw-r--r--Master/texmf-dist/doc/eplain/demo/xhyper.tex190
3 files changed, 278 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/eplain/demo/Makefile b/Master/texmf-dist/doc/eplain/demo/Makefile
new file mode 100644
index 00000000000..45ba215c7aa
--- /dev/null
+++ b/Master/texmf-dist/doc/eplain/demo/Makefile
@@ -0,0 +1,41 @@
+# Makefile for the Eplain demos. This file is public domain.
+
+PDFTEX = pdftex
+DVIPDFM = dvipdfmx
+TEXI2PDF = texi2dvi --pdf
+
+
+.PHONY: all pdftex dvipdfm dvips mostlyclean clean distclean maintainer-clean
+
+
+all: pdftex dvipdfm dvips
+
+#
+# Documents which have to be processed with pdfTeX.
+#
+pdftex: xhyper.pdf lscommnt.pdf
+
+xhyper.pdf: xhyper.tex ctan_lion_350x350.png
+ PDFLATEX=$(PDFTEX) $(TEXI2PDF) xhyper.tex
+
+lscommnt.pdf: lscommnt.tex
+ PDFLATEX=$(PDFTEX) $(TEXI2PDF) lscommnt.tex
+
+#
+# Documents which have to be processed with dvipdfm(x).
+#
+dvipdfm:
+
+#
+# Documents which have to be processed with dvips.
+#
+dvips:
+
+
+clean mostlyclean:
+ rm -f xhyper.{aux,log} lscommnt.log
+
+distclean: clean
+ rm -f xhyper.pdf lscommnt.pdf
+
+maintainer-clean: distclean
diff --git a/Master/texmf-dist/doc/eplain/demo/lscommnt.tex b/Master/texmf-dist/doc/eplain/demo/lscommnt.tex
new file mode 100644
index 00000000000..26d3ec76164
--- /dev/null
+++ b/Master/texmf-dist/doc/eplain/demo/lscommnt.tex
@@ -0,0 +1,47 @@
+% (This file is public domain.)
+% Demonstrate how Eplain can be used to include a TeX source file
+% verbatim, typesetting comments in colored italic typewriter type.
+
+% Load Eplain and LaTeX's color.sty package.
+\input eplain
+\beginpackages \usepackage{color} \endpackages
+\nopagenumbers % Disable page numbers.
+\font\commentfont = cmitt10 % Font for the comments (italic \tt).
+% We'll define some `protected' macros with `@' in their names.
+\makeatletter
+% Define an equivalent of Eplain's \letreturn, to be able to assign
+% various actions to the (active) percent character.
+\begingroup \makeactive\%
+ \gdef\letpercent{\let%}
+\endgroup
+% The listing hook to be called in \setuplistinghook, see below. It
+% makes `%' active and assigns it a `start comment' action.
+\def\hlightcommentslisting{\makeactive\% \letpercent\start@comment}%
+% This is what `%' is aliased to before a comment is started.
+\def\start@comment{%
+ \leavevmode % Needed in the very first line of the input to process
+ % the new par (possibly inserting line number) before we
+ % kick in with the color and stuff.
+ \begingroup % Isolate color and font changes and the redefinitions.
+ \commentfont
+ \color[cmyk]{0.28,1,1,0.35}%
+ \percentchar % Produce the actual `%' and
+ \letpercent\percentchar % make all following `%'s do the same.
+ \letreturn\end@comment % Call \end@comment at end-of-line.
+}
+% \end@comment (alias for ^^M inside a comment) will end the comment
+% started by \start@comment. We make ^^M active temporarily so that
+% the active version of ^^M gets "frozen" into \end@comment.
+\begingroup \makeactive\^^M % Avoid ^^M's from here on.
+ \gdef\end@comment{\endgroup ^^M}%
+\endgroup
+\resetatcatcode % Make `@' again inaccessible for use in macro names.
+
+% Define \setuplistinghook to setup comments highlighting, line
+% numbering and omitting the last (empty) line of input.
+\def\setuplistinghook{\hlightcommentslisting \linenumberedlisting
+ \nolastlinelisting}
+% Isn't this fun? This file typesets itself, with the extra bonus of
+% the pretty-printed comments and numbered source lines!
+\listing{lscommnt}
+\bye
diff --git a/Master/texmf-dist/doc/eplain/demo/xhyper.tex b/Master/texmf-dist/doc/eplain/demo/xhyper.tex
new file mode 100644
index 00000000000..54742cb50b5
--- /dev/null
+++ b/Master/texmf-dist/doc/eplain/demo/xhyper.tex
@@ -0,0 +1,190 @@
+% (This file is public domain.)
+%
+% This file demonstrates the following features of Eplain:
+%
+% - explicit and implicit hyperlinks;
+% - symbolic cross-references;
+% - inserting external graphics using |\includegraphics| from
+% the \LaTeX\ package |graphicx.sty|.
+% - rotating text using |\rotatebox| from |graphicx.sty|.
+%
+% The compiled demo can be downloaded from
+%
+% http://tug.org/eplain/demo
+%
+% In order to compile this file yourself, you will need the CTAN lion
+% drawing by Duane Bibby from
+%
+% ftp://tug.ctan.org/ftpmaint/CTAN_lion/ctan_lion_350x350.png
+%
+% (thanks, |www.ctan.org|). Place the image file in the same
+% directory with this file, and change to that directory. Now, to
+% produce a PDF, run twice the command
+%
+% pdftex xhyper.tex
+%
+% During the first run, Eplain will write the information about the
+% cross-references into |xhyper.aux|, and during the second run this
+% information will be read by Eplain to typeset the references.
+%
+% Demo case:
+%
+% Suppose you are using pdf\TeX, have a figure you want to insert
+% scaled to $200\,pt$ horizontally, and you want this figure to
+% completely fill the PDF viewer's window whenever the reader
+% selects a link pointing to this figure. Additionally, you want to
+% typeset some text as live hyperlinks, clicking on which will start
+% a Web browser and open a URL.
+
+\input eplain
+
+% Load \LaTeX\ packages.
+\beginpackages
+ % |url.sty| provides the |\url| command which we will use to typeset
+ % a URL. We request that |url.sty| be the version from June~27,
+ % 2005, or later, because earlier versions had problems interacting
+ % with plain \TeX.
+ \usepackage{url}[2005/06/27]
+ % |color.sty| provides support for colored text; all hyperlinks are
+ % automatically colored by Eplain when this package is loaded. We give
+ % the |dvipsnames| option because we want to use named colors from the
+ % |dvips| graphics driver.
+ \usepackage[dvipsnames]{color}
+ % Finally, we load |graphicx.sty|, for the macros |\includegraphics|
+ % and |\rotatebox|.
+ \usepackage{graphicx}
+\endpackages
+
+% Remember that hyperlinks are off by default. Therefore, we need to
+% enable them.
+\enablehyperlinks
+
+% Customize some hyperlink options. First, we set border width to~$0$
+% for all links to get rid of the default boxes around links (we
+% prefer colored links over the boxed links). Next, we say that all
+% links created by the |url| hyperlink group (which means the |\url|
+% command from |url.sty|) must be colored using the named color
+% |BlueViolet|.
+\hlopts{bwidth=0}
+\hlopts[url]{colormodel=named,color=BlueViolet}
+
+% Inhibit page numbering (we have only one page).
+\nopagenumbers
+
+% Define a class word for the cross-reference class |figure|. This
+% word, when defined, will be automatically prepended by Eplain to the
+% reference created by |\ref| (read on to see its use).
+\def\figureword{fig.}
+
+% Allocate a count register for the figure's number, and a box
+% register which we'll use to measure dimensions of the image.
+\newcount\fignumber
+\newbox\imgbox
+
+% Now comes the fun part--constructing the figure for the image of the
+% \CTAN\ lion. We define a macro
+%
+% \fig{LABEL}{FILENAME}{CAPTION}{WIDTH}
+%
+% which creates a figure using LABEL for the cross-reference and
+% hyperlink label, reading the image from file FILENAME, using CAPTION
+% to name the figure, and WIDTH to scale the image horizontally.
+\def\fig#1#2#3#4{%
+ % Leave some space above the figure. This will also ensure that we
+ % are in the vertical mode before we produce a |\vbox|.
+ \medskip
+ % Advance the figure number. |\global| ensures that the change to
+ % the count register is global, even when |\fig| is buried inside a
+ % group.
+ \global\advance\fignumber by 1
+ % We use |\includegraphics| (from |graphicx.sty|) to load the image,
+ % scaled to the specified width, into our ``measuring'' box
+ % |\imgbox|.
+ \setbox\imgbox = \hbox{\includegraphics[width=#4]{#2}}%
+ % To make the demo even more exciting, let's put the figure's
+ % caption to the left of the image into the |\indent| space of the
+ % new paragraph, and rotate the caption~$90^\circ$.
+ \textindent{%
+ \rotatebox{90}{F{\sc IGURE}~\the\fignumber. #3}%
+ }%
+ % Continue the paragraph by constructing a |\vbox| with the image of
+ % the lion. We use |\definexref| to define the cross-reference
+ % label.
+ \vbox{%
+ % In addition to the cross-reference label, |\definexref| will
+ % create a hyperlink destination with the same label. Therefore,
+ % we customize this destination to do what we need. We say that
+ % destination type for the hyperlink group |definexref| (to which
+ % |\definexref| belongs) should be |fitr|. This destination type
+ % will magnify the rectangle specified by the options |width|,
+ % |height| and |depth| to the PDF viewer's window. Therefore, we
+ % set those options accordingly with |\hldestopts| (notice the use
+ % of |depth| instead of |height|---we will want the rectangle to
+ % extend {\it downward}, to cover the image which will come
+ % next). Notice that these settings will be isolated within the
+ % current group (i.e., the |\vbox| we're constructing).
+ \hldesttype[definexref]{fitr}%
+ \hldestopts[definexref]{width=\wd\imgbox,height=0pt,depth=\ht\imgbox}%
+ % We define a symbolic label so that we can later refer
+ % to the figure with |\ref|. The command |\definexref| does
+ % exactly that. The last argument to |\definexref| specifies
+ % class of the label, which determines the word used by |\ref| in
+ % front of the reference text (remember that we've defined
+ % |\figureword| above).
+ \definexref{#1}{\the\fignumber}{figure}%
+ % Finally, produce the image which we've been stashing in the box
+ % register |\imgbox|.
+ \box\imgbox
+ }%
+ \medskip
+}
+
+% Create the figure.
+\fig{CTANlion}{ctan_lion_350x350}{Lion in the archives}{200pt}
+
+% Finished with the fun part, we can relax and typeset some
+% hyperlinks. The easiest way to do that is to use the |\ref|
+% cross-reference command. We can even pass an optional argument
+% (|the lion in|), which will be placed before the class word (|fig.|)
+% and become part of the link (to make sure the reader does not have
+% to aim too hard).
+Show me \ref[the lion in]{CTANlion}.
+
+% If you are the restless kind, here's another way to create a
+% hyperlink to the image: we create a link explicitly by using
+% |\hlstart ... \hlend|. We don't specify the link type, therefore
+% the default type |name| will be used (these are ``named links'',
+% i.e., links pointing to destinations identified by labels). In the
+% options argument, we specify that the border of the link should be
+% inverted when the user clicks the link (|hlight=O|), and also set
+% special color for this link, overriding the default dark-red. The
+% label for the destination is the same as the cross-reference label,
+% |CTANlion|.
+Show me
+\hlstart{}{hlight=O,colormodel=named,color=OliveGreen}{CTANlion}
+ the CTAN lion\hlend.
+
+% Let's now point somewhere outside our document. Eplain homepage is
+% a good target. In the similar spirit, let's consider two
+% approaches. The easy one is to use the |\url| command from
+% |url.sty|. Remember that we have customized the color of |url|
+% hyperlinks, so this one will show up with a different color than the
+% default dark-red.
+Take me to \url{http://tug.org/eplain}.
+
+% The second approach is to create an explicit URL link. We specify
+% yet another border highlighting mode, |P|, which means that the
+% region underneath the bounding box of the link will be drawn inset
+% into the page. Also, let's set the color of the hyperlink to an RGB
+% color |0.4,0.1,0.4|. Since we cannot use commas to separate the
+% color elements inside the options parameter to |\hlstart| (commas
+% there separate options), we have to first create a user-defined
+% color with |\definecolor| from |color.sty|, and use that in
+% |\hlstart|.
+\definecolor{mycolor}{rgb}{0.4,0.1,0.4}
+
+Take me to
+\hlstart{url}{hlight=P,colormodel=,color=mycolor}{http://tug.org/eplain}
+ Eplain homepage\hlend.
+
+\bye