|
"http://www.w3.org/TR/REC-html40/loose.dtd">
Generating HTML constructs
http://pauillac.inria.fr/~maranget/index.html ),
you should do something like this :
\ahref{http://pauillac.inria.fr/\home{maranget}/index.html}{his home page}Given the frequency of ~ , # etc. in urls,
this is annoying. Moreover, the immediate solution
\ahref{\verb" ... /~maranget/..."}{his home page} does not
work, since LATEX forbids verbatim formatting inside command arguments.Fortunately, the url package provides a very convenient \url command that acts like \verb and can appear in
other command arguments
(unfortunately, this is not the full story, see section B.17.6).
Hence, provided the url package is loaded,
a more convenient reformulation of the example above is :
\ahref{\url{http://pauillac.inria.fr/~maranget/index.html}}{his home page}Or even better : \urldef{\lucpage}{\url}{http://pauillac.inria.fr/~maranget/index.html} \ahref{\lucpage}{his home page}It may seem complicated, but this is a safe way to have a document processed both by LATEX and HEVEA. Drawing a line between url typesetting and hyperlinks is correct, because users may sometime want urls to be processed and some other times not. Moreover, HEVEA (optionnaly) depends on only one third party package: url, which as correct as it can be and well-written. In case the \url command is undefined
at the time \begin{document} is processed, the commands
\url , \oneurl and \footurl are defined as
synonymous for
\ahref , \ahrefurl and \footahref , thereby
ensuring
some compatibility with older versions of HEVEA.
Note that this usage of \url is deprecated.
Those declarations follow HTML conventions for colors. There are sixteen predefined colors:
\htmlcolor{ number} ,
where number is a six digit hexadecimal number specifying a
color in the RGB space. For instance, the following declarations
change font color to dark gray:\htmlcolor{404040}
\imgsrc command
becomes handy when one has images both in Postscript and GIF format.
As explained in section 6.3, Postscript images can
be included in LATEX documents by using the \epsfbox
command from the epsf package.
For instance, if screenshot.ps is an encapsulated Postscript
file, then a doc.tex document can include it by:
\epsfbox{screenshot.ps}We may very well also have a GIF version of the screenshot image (or be able to produce one easily using image converting tools), let us store it in a screenshot.ps.gif file. Then, for HEVEA to include a link to the GIF image in its output, it suffices to define the \epsfbox command in the macro.hva file
as follows:
\newcommand{\epsfbox}[1]{\imgsrc{#1.gif}}Then HEVEA has to be run as: # hevea macros.hva doc.texSince it has its own definition of \epsfbox , HEVEA will
silently include a link the GIF image and not to the Postscript image.If another naming scheme for image files is prefered, there are alternatives. For instance, assume that Postscript files are of the kind name.ps, while GIF files are of the kind name.gif. Then, images can be included using \includeimage{ name} , where
\includeimage is a specific user-defined command:
\newcommand{\includeimage}[1]{\ifhevea\imgsrc{#1.gif}\else\epsfbox{#1.ps}\fi}Note that this method uses the hevea boolean register (see section 5.2.3). If one does not wish to load the hevea.sty file, one can adopt the slightly more verbose definition: \newcommand{\includeimage}[1]{% %HEVEA\imgsrc{#1.gif}% %BEGIN LATEX \epsfbox{#1.ps} %END LATEX }When the Postscript file has been produced by translating a bitmap file, this simple method of making a GIF image and using the \imgsrc command
is the most adequate.
It should be prefered over using the more automated image file
mechanism (see section 6),
which will translate the image back from
Postscript to bitmap format and will thus degrade it.
\begin{rawhtml} and
\end{rawhtml} is echoed verbatim into the HTML output file.
For avoiding to break HTML element nesting, the rawhtml
environment should be used only at toplevel (i.e. not within another
environment), and it should contain only HTML text that makes sense
alone
(e.g. \begin{rawhtml}<TABLE><ALIGN=right>\end{rawhtml} ...
\begin{rawhtml}</TABLE>\end{rawhtml} is
dangerous. In that case,
use the internal macros \@open and \@close of
the following section instead).When HEVEA is given the command line option ``-O'', checking and optimization of text-level elements in the whole document takes place. As a consequence, incorrect HTML introduced by using the rawhtml environment may be detected at a later stage. For the document to remain processable by LATEX, it must load the hevea.sty style file (see section 5.2).
Normally, user source code should not use them, since their behavior may change from one version of HEVEA to another and because using them incorrectly easily crashes HEVEA. However:
\begin{ env} ...
\end{ env} get
translated into HTML block-level elements < block
attributes> ... </ block> .
More specifically, such block level elements are opened by the
internal macro \@open and closed by the internal macro
\@close .
As a special case, LATEX groups { ... }
get translated into HTML groups, which are shadow block-level
elements with neither opening tag nor closing tag.It is important to notice that primitive arguments are processed (except for the \@print primitive). Thus,
some characters cannot be given directly (e.g. # and
% must be given as \# and \% ).
\@style , \@fontsize and
\@fontcolor . Block-level elements (and HTML groups)
delimit the effect of such declarations.
center environment:
\newenvironment{center}{\@open{DIV}{ALIGN=center}}{\@close{DIV}}Another example is the definition of the \purple
color declaration (see section 8.1.2):
\newcommand{\purple}{\@fontcolor{purple}}HEVEA does not feature all text-level elements by default. However one can easily use them with the internal macro \@style .
For instance this is how you can make all emphasized text blink:
\renewcommand{\em}{\@style{EM}\@style{BLINK}}Then, here is the definition of a simplified \imgsrc
command (see section 8.1.1), without its optional argument:
\newcommand{\imgsrc}[1] {\@print{<IMG SRC="}\@getprint{#1}\@print{">}}Here, \@print and \@getprint are used to output
HTML text, depending upon wether this text requires processing or not.
Note that \@open{IMG}{SRC="#1"} is not correct,
because the element IMG consists in a single tag, without a
closing tag.Another interesting example is the definition of the command \@doaelement ,
which HEVEA uses internaly to output A elements.
\newcommand{\@doaelement}[2] {{\@nostyle\@print{<A }\@getprint{#1}\@print{>}}{#2}{\@nostyle\@print{</A>}}The command \@doaelement takes two arguments: the first
argument contains the opening tag attributes; while the second element is
the textual content of the A element.
By contrast with the \imgsrc exemple above,
tags are emitted inside groups where styles are canceled by using the
\@nostyle declaration.
Such a complication is needed, so as to avoid breaking proper nesting
of text-level elements.Finally, here is an example of direct block opening. The bgcolor environment from the color package locally changes background color (see section B.14.2.1). This environment is defined as follows: \newenvironment{bgcolor}[2][CELLPADDING=10] {\@open{TABLE}{#1}\@open{TR}{}\@open{TD}{BGCOLOR=\@getcolor{#2}}} {\@close{TD}\@close{TR}\@close{TABLE}}The bgcolor environment operates by opening a HTML table ( TABLE ) with only one row (TR ) and cell (TD ) in
its opening command, and closing all these elements in its closing
command. In my opinion, such a style of opening block-level elements
in environment opening commands and closing them in environment
closing commands is good style.The one cell background color is forced with a BGCOLOR
attribute.
Note that the mandatory argument to \begin{bgcolor} is the
background color expressed as a high-level color, which therefore
needs to be translated into a low-level color by using the
\@getcolor internal macro from the color package.
Additionally, \begin{bgcolor} takes HTML attributes
as an optional argument. These attributes are the ones of the
TABLE element. |