52
6 Linking slides from prosper to T
E
X4ht
This section deals with the issue of creating hypertext links when using the
package prosper [5], and more specically hypertext links to html documents
created with T
E
X4ht. This is not meant as a guide to prosper, as the docu-
mentation that comes with the package is a good guide in itself, and since it
is not very dicult to learn anyway. But we mention that prosper allows you,
as a LAT
E
Xuser, to create high-quality presentation slides merely with simple
LAT
E
Xcode. The pdf le that results from this process is comparable to those
created with Microsoft’s PowerPoint. The most important advantages of using
prosper, is that it is free and that it supports all typical LAT
E
Xstructures, such
as mathematics. (We all know that PowerPoint is bad at this.)
Why bother with these hyperlinks?
Imagine yourselfata conference, meeting, orwhatever, displaying yourslides
for the audience. Maybe you are presenting your latest ndings in time-travel
technology or mind transfer serums. Then, at some point, you refer to some of
your articles showing detailed calculations or witty quotes. With thehyperlinks
inside your slides, you may click on this anchor and, behold, the web browser
pops up displaying the exact contents of your article! Neat.
Moreover, with the knowledge of how to put hyperlinks into prosper, you
may also link to regular web pages with relevant content. This might also be
valuable. (But then, you don’t need most of the material in this section.)
6.1 The hyperref package
The hyperref package provides a
exible interface to hypertext links. It is in-
cluded when you include prosper. This means that most of the options oered
by hyperref is set \behind the curtains," but for most uses this should not be a
hindrance. A thorough description of hyperref is found in [1], and we will only
deal with the basics here.
Aplain, vanilla hypertext link is inserted with the \href command:
\href{url}{text}
Here, urlis thefully expanded URL to the desired page, and text is theanchor
shown visually. Note that characters such as # and ~ should not be escaped.
Note also that the link must be fully expanded. If not, the link wil typically
get a file: in front. This unfortunately makes thedocument less portable. To
overcome this problem a bit, a command \hyperbaseurl is provided.7 Set this
to e.g. http://www.something.com/user/ and you can omitthefull expansion
of the hyperlinks. (You may still expand external links, of course.)
Because of the colorizing parameters being obscured by the early inclusion
of hyperref, one has to use other means for creating colored links. One way is
7
Due to a minor (?) bug, inserting a tilde in the adress results in an error. Try to work
around this in some way, e.g. by using \string~ to insert a tilde.
12
How to C#: Basic SDK Concept of XDoc.PDF for .NET create, load, combine, and split PDF file(s), and add, create, insert, delete, re-order, copy, paste, cut This class describes bookmarks in a PDF document.
adding bookmarks to a pdf; excel pdf bookmarks
48
\newcommand{\myhref}[2]{\href{#1}{\begin{blue}%
\underline#2\end{blue}}}
whose usage is the same as the original \href command.
6.2 The missing links inside T
E
X4ht
Now, we turn to the creation of human readable anchors inside the html les
generated with T
E
X4ht. We wish to be able to direct our hypertext links inside
the prosper presentation to a given chapter, section or page. In html, this is
donewith <a name=’whatnot’> tags; anchor tags. T
E
X4ht creates such tagsby
default for internal cross linking between equation references, gure references
and so on. Unfortunately, the format of these are not known a priori, and we
must supply reliable tags ourselves.
This might seem clumsy at rst: why not use the tags already present? The
simple implementation we choose and the usage proves the method to be ne,
though. Analyzing T
E
X4ht’s behaviour may be a tedious task, and that’s why
we decide on the presented technique.
The main ingredients of the implementation is to exploit T
E
X4ht’s \hooks."
When theauthor issues e.g. a sectioning command, congurable hooksgenerate
html material in the tex4ht post-processing stage. This allows us to create
anchors with literal description of the section. The needed congurations and
macros are collected in customlinks.tex, whose usage is described next.
To invokethecustomhooks, simply \input the macro leimmediately after
the \beginfdocumentg command. On every chapter, section and subsection, a
html anchor is created. One can also issue custom-made anchors with the
commands \customlink and \pagelink:
\pagelink creates an anchor to the current page on the form pnnn, where
nnn is the page. This feature seems rather silly, but it might prove useful.
\customlinkfnameg creates an anchornamed nameatthecurrentposition
in the web document.
Note: When using these commands, do not insert empty lines on both sides of
them. If you do, it will result in an empty but visible paragraph in the
document. (The ancors still work, of course, whether you remember this
or not.)
Whenever a custom hook is encountered, the macros issue a message to the
log. To extract the interesting messages, issue the command
cat doc.log | grep Customlink >links.txt
to generate a le containing a description of the links. Typically a line reads:
--- Customlinks says: Link to section 2.1: doc.html#sec2-1
13
VB.NET PDF: Basic SDK Concept of XDoc.PDF create, load, combine, and split PDF file(s), and add, create, insert, delete, re-order, copy, paste, cut This class describes bookmarks in a PDF document.
export pdf bookmarks; display bookmarks in pdf
60
So, when one needs to link to section 2.1, use this link.
Thecustomlinks.texcontains onlybasicLAT
E
Xprogramming, so extending
it to ones own need should be no dicult task. As for now, starred sections are
not implemented, for example.
The le customlinks.tex is available alongside this document from [6]. In
addition, it is included in the le package described in section 5.
6.3 An example
On the web page [6] you may view an example showing how to link prosper
documents to html documents and html documents created with T
E
X4ht in
particular.
The example consists of several les:
dracula.tex: This is the document that is being converted with T
E
X4ht.
dracula.html: This is the document after conversion with T
E
X4ht.
customlinks.tex: The previously mentioned le that denes T
E
X4ht
hooks for customized anchors inside the LAT
E
Xdocument.
slides.tex: Prosper slides utilizing the anchors genereated during com-
pilation of dracula.tex.
slides.pdf: The compiled prosper presentation; clickable and all.
Take a look at the source codes. Hopefully this will in conjunction with the
above paragraphs be informative.
7 Making a Simula report from your L
A
T
E
Xdoc-
ument
In this section we state theprocedurefor adding the ocial Simula report cover
to your L
A
T
E
X document. We include this description inside this document,
because usually when creating Simula reports, one also publish it on the web in
html format | thus having the recipes all in one place might be a good idea.
Adding the Simula cover is really simple, but remember that some L
A
T
E
X
packages that you use might turn out to be incompatible with the Simula cover
style. We will return to this issue later.
For moreinformationontheusageandbugreporting, seetheSimula intranet
[7].
To add a Simula-cover, three simple steps are needed:
1. Include the simulacover package just after the \documentclass declara-
tion:
\usepackage{simulacover}
14
49
2. If you need or want another way to display author names etc. on the
cover, add one or more of the following commands:
\simdoctitlefAlternate titleg
\simdocauthorfAlternate author descriptiong
\simdoctypefFor example ‘‘memo’’g
\simdoctextfThis goes on the front cover as wellg
\simdocnumberfReport numberg
3. Add the command
\makesimulacover
just before the \maketitle command. This will create the cover with the
author names, the title of the document and so on.
The simulacover package is installed on Simula, and is available on all local
machines. Ifyouwanttocompileyourdocumentona laptop oranother machine
running L
A
T
E
X, get a copy of the latest8 version of the package and put it into
the same directory as your document. L
A
T
E
Xwill then nd the package and
include it properly. There is no need for actually installing it to your L
A
T
E
X
system.
Ifitturnsoutthatfor somereason, yourdocumentdoesnotcompilecorrectly
ordoes notcompileatall, theproblemisprobablythatinclusion ofsomepackage
interfers with simulacover. Currently, the fancybox package is known to exhibit
this behaviour.
Asimple solution to this problem is to create a new document containing
only the Simula cover, and no text. Create a PostScript version of this and add
the two rst pages to the PostScript version of your original document.
Alternatively, work around the incompatibilities in some other way; using
dierent packages or similar.
8 Listings
Here are the listings for various les mentioned. They can also be downloaded
from [6].
8.1 cscript.sh
#!/bin/bash
echo ’CSCRIPH.SH -- convert dvi to bitmap.’
8
Note: Theversion on the Simula intranet web siteisat thetime of writing outdated! We
suggest that onelocates thepackage on oneof Simula’s Linux stationsand copies thisto ones
own computer.
15
72
#
# verison 1.5
#
# exit statii and their meanings:
# 0 - success
# 1 - bad command line
#proper invocation:
# cscript.sh thedvifile thepage theoutputfile quality
#
# quality is a parameter describing the quality of the converting process
# when using the horribly slow plan-b-method.
# 0-dirty, 1-low, 2-medium, 3-high.
#
# check if command line arguments exists
if [[ ! "$1" || ! "$2" || ! "$3" || ! "$4" ]]
then
echo "CSCRIPT.SH> Error: bad command line"
echo "
proper invocation: CSCRIPT.SH thedvifile thepagenumber theoutputfile quality"
exit 1
fi
#check quality settings ...
quality=$4
if [[ "$quality" -lt 0 ]]
then
quality=0
fi
if [[ "$quality" -gt 3 ]]
then
quality=3
fi
echo "CSCRIPT.SH> quality set to $quality"
#try to convert with dvi2bitmap.
rm -f $3
success=0
if ./dvi2bitmap --font-mode=ibmvga --page-range=$2 --magnification=4 -s 4 --output-type=png --resolution=110 --process=transparent=false --output=$3 $1
then success=1
fi
#./dvi2bitmap -fp /var/spool/texmf/pk/ibmvga/public/cm:/var/spool/texmf/pk/ibmvga/public/latex::/var/spool/texmf/pk/ibmvga/ams/cmextra -fm ibmvga -Pt -pp $2 -m 4 -s 4 -t png -r 110 -o $3 $1
#check if the outputfile was generated.
#if not, create image with dvips/gs/convert.
if [[ -e "$3" ]]
#if (( success = 1 ))
then
echo "CSCRIPT.SH> dvi2bitmap made it!"
# enhance the bitmap.
#convert -unsharp 1.0x0.5 $3 fisk_og_slips.gif
#convert fisk_og_slips.gif $3
else
echo "CSCRIPT.SH> dvi2bitmap failed! running the dvips/gs/convert-process..."
dvips -Pcmz -Pamz -mode ibmvga -D 220 -f $1 -pp $2 > TEMPORARY.ps
if [[ "$quality" = 0 ]]
then
res_str=’-r25x25’
scale_str=’440%’
fi
if [[ "$quality" = 1 ]]
then
res_str=’-r110x110’
scale_str=’100%’
fi
if [[ "$quality" = 2 ]]
then
res_str=’-r160x160’
scale_str=’68.75%’
fi
if [[ "$quality" = 3 ]]
then
res_str=’-r220x220’
scale_str=’50%’
fi
16
75
gs -sDEVICE=ppm -sOutputFile=TEMPORARY.ppm $res_str -q -dbatch -dNOPAUSE TEMPORARY.ps -c quit
convert -crop 0x0 -density 110x110 -antialias -scale $scale_str -transparent ’#FFFFFF’ TEMPORARY.ppm $3
rm TEMPORARY.ps
rm TEMPORARY.ppm
fi
echo "CSCRIPT.SH> finished."
8.2 customlinks.tex
%
% These are commands that configure tex4ht to produce internal
% human readable links into the HTML code.
%
\newcommand{\logcomment}{ --- Customlinks says: }
\newcommand{\chapterlink}{\HCode{<a name=’ch\arabic{chapter}’></a>}}
\newcommand{\sectionlink}{\HCode{<a name=’sec\arabic{chapter}-\arabic{section}’></a>}}
\newcommand{\subsectionlink}{\HCode{<a name=’subsec\arabic{chapter}-\arabic{section}-\arabic{subsection}’></a>}}
\newcommand{\subsubsectionlink}{\HCode{<a name=’subsubsec\arabic{chapter}-\arabic{section}-\arabic{subsection}-\arabic{subsubsection}’></a>}}
\newcommand{\reportchapterlink}{\typeout{\logcomment Link to
chapter \thechapter: \FileName\#ch\arabic{chapter}}}
\newcommand{\reportsectionlink}{\typeout{\logcomment Link to
section \thesection:
\FileName\#sec\arabic{chapter}-\arabic{section}}}
\newcommand{\reportsubsectionlink}{\typeout{\logcomment Link to
subsection \thesubsection:
\FileName\#subsec\arabic{chapter}-\arabic{section}-\arabic{subsection}}}
\newcommand{\reportsubsubsectionlink}{\typeout{\logcomment Link to
subsubsection \thesubsubsection:
\FileName\#subsubsec\arabic{chapter}-\arabic{section}-\arabic{subsection}-\arabic{subsubsection}}}
\newcommand{\reportcustomlink}[1]{\typeout{\logcomment Custom link named ’#1’: \FileName\##1 }}
\newcommand{\customlink}[1]{\HCode{<a name=’#1’></a>}\reportcustomlink{#1}}
\newcommand{\thispage}{\arabic{page}}
\newcommand{\reportpagelink}{\typeout{\logcomment Page-link at page
\thispage: \FileName\#p\thispage}}
\newcommand{\pagelink}{\HCode{<a name=’p\thispage’></a>}\reportpagelink}
\Configure{chapter}{\chapterlink\reportchapterlink}{}{}{}
\Configure{section}{\sectionlink\reportsectionlink}{}{}{}
\Configure{subsection}{\subsectionlink\reportsubsectionlink}{}{}{}
\Configure{subsubsection}{\subsubsectionlink\reportsubsubsectionlink}{}{}{}
%
% End of internal link code.
%
%
% To generate a report of links generated:
%
%
cat bok.log | grep Customlinks > links.txt
%
%
%
% Note that when inserting ‘‘custom links,’’ don’t insert blank lines
% after the \customlink-command. This will generate an extra (empty
% but visible) paragraph!
%
8.3 tex4ht.env
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tex4ht.env / .tex4ht
%
%
%
% Notes:
%
% 1. empty lines are harmful
%
% 2. place this file in your work
%
%
directory and/or root directory
%
%
and/or in directory ‘xxx’ of your
%
%
choice. In the latest case, compile %
%
tex4ht.c with ‘#define HTFDIR xxx’, %
17
52
%
or provide the address of the file %
%
to tex4ht throught the -e switch
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% * Replace ‘path’ and ‘tfmpath/...’
%
% * A ! requests recursive search into
%
%
subdirectories
%
% * Multiple entries of each type are
%
%
allowed
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ttfmpath/tex/texmf/fonts/tfm/!
%ipath/tex4ht.dir/ht-fonts/iso8859/!
%ipath/tex4ht.dir/ht-fonts/alias/!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replace ‘path’
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% bookkeeping for searched files
%lpath/tex4ht.dir/tex4ht.fls
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Default scripts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s--- needs --- %%1.idv[%%2] ==> %%3 ---
b--- characters ---
g.png
% remove protection
S*
%
% invoke cscript.sh; a script to convert from dvi to bitmap.
%
G./cscript.sh %%1 %%2 %%3 2
%
% t4ht -d%%2
Mmv %%1 %%2
Ccp %%1 %%2
% t4ht -d%%2 -m%%1
Achmod %%1 %%2%%3
% empty gifs
Ecp empty.pic %%1%%2
% validations, XSTL tranformations,...
Xmake -f NSGMLS name=%%1 ext=%%2
% end of file
18
Documents you may be interested
Documents you may be interested