-
Notifications
You must be signed in to change notification settings - Fork 11
/
text.tex
6895 lines (6070 loc) · 254 KB
/
text.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\usepackage{a4}
\usepackage{fullpage}
\usepackage{makeidx}
\usepackage{texnames}
\usepackage{url}
\usepackage{../hevea}
\usepackage{listings}
\usepackage{isolatin1}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{ifthen}\usepackage{array}
\usepackage{graphics}
\usepackage{mathpartir}
\usepackage{alltt}
\usepackage{moreverb}
\usepackage[dvips]{color}
\definecolor{abricot}{cmyk}{0,0.32,0.52,0}
\input{macros.tex}
\makeindex
\input{version.tex}
%HEVEA\usepackage{color}%for echo to image file
%\colorsections{20}
\newtheorem{example}{Example}
\title{\hevea{} User Documentation\\
{\normalsize Version~\heveaversion}}
\author{Luc Maranget\thanks{Inria Rocquencourt -- BP 105, 78153 Le
Chesnay Cedex. {\tt \mailto{Luc.Maranget@inria.fr}}}}
\date{\today}
\addtocounter{tocdepth}{-1}
\ifdevrelease
\urldef{\ftpbase}{\url}{ftp://ftp.inria.fr/INRIA/moscova/hevea/unstable}
\else
\urldef{\ftpbase}{\url}{ftp://ftp.inria.fr/INRIA/moscova/hevea}
\fi
\urldef{\httpbase}{\url}{http://hevea.inria.fr/}
\def\stylex{padding:1ex;color:navy;border:solid navy;}
\newstyle{.subsectionex}{\stylex}
\def\verbstyle{margin:1ex 1ex;padding:1ex;background:\@getstylecolor{paragraph};}%
\newstyle{.verbatim}{\verbstyle}%
\newstyle{.myverbatim}
{margin:1ex 3ex;padding:1ex;
color:maroon;
background:\@getstylecolor[named]{Apricot}}
\newcommand{\emitstyle}[2]
{\newstyle{.toc#1}{list-style:none;border-left:1ex solid #2;padding:0ex 1ex;}}
\emitstyle{1}{\@getstylecolor{Sepia}}
\emitstyle{2}{\@getstylecolor{Brown}}
\emitstyle{3}{\@getstylecolor{Tan}}
\emitstyle{4}{\@getstylecolor{Melon}}
\newstyle{.xtitle}
{text-align:center;margin:1ex auto;padding:2ex;color:navy;border:solid navy;}
\newstyle{.xtitlerest}{font-variant:small-caps;}
\newstyle{.ruled}{border:solid black;padding:1ex;background:\#eeddbb;color:maroon}
\newstyle{.xmathpar}{background:yellow;margin-left:2ex;margin-right:auto;}
\setlinkstext
{\imgsrc[ALT="Previous"]{previous_motif.gif}}
{\imgsrc[ALT="Up"]{contents_motif.gif}}
{\imgsrc[ALT="Next"]{next_motif.gif}}
%%DOCUMENT START HERE
\begin{document}
\maketitle
\begin{htmlonly}
\ifhtml
\def\locversion{\ifdevrelease\releasedate\else\heveaversion\fi}
\@hr[]{}{}
This manual also exists in
\ahref{\ftpbase/hevea-\locversion-manual.ps.gz}{compressed Postscript},
\ahref{\ftpbase/hevea-\locversion-manual.pdf}{PDF}, and as
a \ahref{\ftpbase/hevea-\locversion-manual.tar.gz}{bundle of HTML files}.
\@hr[]{}{}
\fi
\end{htmlonly}
\begin{abstract}
\hevea{} is a \LaTeX{} to
\html{} translator.
The input language is a fairly complete subset of \LaTeXe{} (old
\LaTeX{} style is also accepted) and the
output language is {\html} that is (hopefully) correct with respect to
version 4.0 transitional.
Recent versions of most browsers offer support for Unicode entities,
albeit to different extents. \hevea{} exploits this fact to translate
various math symbols used in \LaTeX. As a result, almost the entire set
of math symbols, including the {\tt amssymb} ones, are correctly
rendered. The use of the symbol font browsers is no
longer the default.
\hevea{} understands \LaTeX{} macro definitions. Simple user style
files are understood with little or no modifications.
Furthermore, \hevea{} customization is done by writing \LaTeX{} code.
%Among latest additions are support for style-sheets, babel, and some
%proof and math packages.
\hevea{} is written in Objective Caml, as many lexers. It is
quite fast and flexible. Using \hevea{} it is possible to translate
large documents such as manuals, books, etc. very quickly. All
documents are translated as one single {\html} file. Then, the output
file can be cut into smaller files, using the companion program~\hacha.
\hevea{} can also be instructed to output plain text or info files.
Information on \hevea{} is available at \ahrefurl{\heveaurl}.
\end{abstract}
\clearpage
\cutdef{section}
\tableofcontents
\cutend
\begin{htmlonly}
This document consists in three parts, a tutorial introduction, a
reference manual and some practical information. The latter part
includes a small \ahrefloc{@index}{index}.
\end{htmlonly}
\clearpage
\part{Tutorial}
\pdfpart{10}{Tutorial}
\label{usermanual}
\cutdef{section}
\section{How to get started}\label{getstarted}
Assume that you have a file, ``\texttt{a.tex}'', written in \LaTeX, using the
\filename{article}, \filename{book} or \filename{report} style. Then,
translation
is achieved by issuing the command:
\begin{verbatim}
# hevea a.tex
\end{verbatim}
Probably, you will get some warnings. If
\hevea{} does not crash, just ignore them for the moment
(Section~\ref{trouble} explains how to correct errors).
If everything goes fine, this will produce a new file,
``\texttt{a.html}'', which you can visualize through a {\html} browser.
If you wish to experiment \hevea{} on small \LaTeX{} source fragments,
then launch \hevea{} without arguments. \hevea{} will read its
standard input and print the translation on its standard output.
For instance:
\begin{verbatim}
# hevea
$x \in {\cal E}$
^D
<I>x</I> ∈ <FONT COLOR=red> <I>E</I></FONT>
\end{verbatim}
You can find some more elaborate \footahref{\heveaurl/examples/index.html}{examples} in the on-line
documentation.
\section{Style files}
\LaTeX{} style files are files that are not intended to produce output, but
define document layout parameters, commands, environments, etc.
\subsection{Standard base styles}
The base style of a \LaTeX{} document is the argument to the
\verb+\documentclass+ command (\verb+\documentstyle+ in old style).
Normally, the base style of a document defines the structure and
appearance of the whole document.
\noindent\hevea{} really knows about two \LaTeX{} base styles,
\filename{article} and \filename{book}.
Additionally, the \filename{report} base style is recognized and
considered equivalent to \filename{book} and the
\filename{seminar} base style for making slides is recognized and
implemented by small additions on the \filename{article} style.
Base style \filename{style} is implemented by an \hevea{} specific
style file \filename{style}\verb+.hva+.
More precisely, \hevea{} interprets
\verb+\documentclass{+\filename{style}\verb+}+ by attempting to load
the file \filename{style}\verb+.hva+ (see section~\ref{comline} on where
\hevea{} searches for files).
Thus, at the moment, \hevea{} distribution includes the files,
\texttt{article.hva}, \texttt{book.hva}, etc.
\subsection{Other base styles}\label{otherbase}
Documents whose base style is not recognized by \hevea{} can be
processed when the unknown base style is a derivation of a
recognized base style.
Let us assume that \texttt{mydoc.tex} uses an exotic
base style such as \filename{acmconf}. Then, typing
\verb+hevea mydoc.tex+ will yield an error, since
\hevea{} cannot find the \texttt{acmconf.hva} file:
\begin{verbatim}
# hevea.opt mydoc.tex
mydoc.tex:1: Warning: Cannot find file: acmconf.hva
mydoc.tex:1: Error while reading LaTeX: No base style
Adios
\end{verbatim}
This situation is avoided by invoking \hevea{} with the known
base style file \texttt{article.hva} as an extra argument:
\begin{verbatim}
# hevea article.hva mydoc.tex
\end{verbatim}
The extra argument instructs
\hevea{} to load its \texttt{article.hva}
style file before processing \texttt{mydoc.tex}.
It will then ignore the document base style specified by
\verb+\documentclass+ (or \verb+\documentstyle+).
Observe that the fix above works because the \filename{acmconf} and
\filename{article} base styles look the same to the document (i.e., they define
the same macros).
More generally, most base styles that are neither
\textit{article} nor \textit{book} are in fact variations
on either two of them.
However, such styles usually provides extra macros.
If users documents use these macros, then users should also instruct
\hevea{} about them (see section~\ref{dontknow}).
Finally, it is important to notice that
renaming a base style file \filename{style}\verb+.cls+ into
\filename{style}\verb+.hva+ will not work in general.
As a matter of fact, base style files are \TeX{} and not \LaTeX{} source and
\hevea{} will almost surely fail on \TeX-ish input.
\subsection{Other style files}
A \LaTeX{} document usually loads additional style files, by using
the commands \verb+\input+ or \verb+\usepackage+ or \verb+\input+.
\subsubsection{Files loaded with \texttt{\char92 input}}
Just like \LaTeX{}, \hevea{} reacts to the construct
\verb+\input{+\textit{file}\verb+}+ by loading the file
\textit{file}. (if I got it right, \hevea{} even follows \TeX{} crazy
convention on ``\texttt{.tex}'' extensions).
As it is often the case, assume that the document \texttt{mydoc.tex} has a
\verb+\input{mymacros.tex}+ instruction in its preamble, where
\texttt{mymacros.tex} gathers custom definitions.
Hopefully, only a few macros give rise to trouble: macros that performs fine
typesetting or {\TeX}ish macros.
Such macros need to be rewritten, using basic \LaTeX{}
constructs (section~\ref{trouble} gives examples of macro-rewriting).
The new definitions are best collected in a style file,
\texttt{mymacros.hva} for instance.
Then, \texttt{mydoc.tex} is to be translated by issuing the command:
\begin{verbatim}
# hevea mymacros.hva mydoc.tex
\end{verbatim}
The file \texttt{mymacros.hva} is processed before
\texttt{mydoc.tex} (and thus before \texttt{mymacros.tex}).
As a consequence of \hevea{} behavior with respect to
definition and redefinition (see section~\ref{usermacro}),
the macro definitions in \texttt{mymacros.tex}
override the ones in \texttt{mymacros.tex}, provided
the document original definitions are performed by \verb+\newcommand+
(or \verb+\newenvironment+).
Another situation is when \hevea{} fails to process a whole
style file. Usually, this means that \hevea{} crashes on that style
file.
The basic idea is then
to write a \texttt{mymacros.hva} style file that contains alternative
definitions for all the commands defined in \texttt{mymacros.sty}.
Then, \hevea{} should be instructed
to load \texttt{mymacros.hva} and not to load \texttt{mymacros.tex}.
This is done by invoking \texttt{hevea} as follows:
\begin{verbatim}
# hevea mymacros.hva -e mymacros.tex mydoc.tex
\end{verbatim}
Of course, \texttt{mymacros.hva} must now contain replacements for
all the useful macros of \texttt{mymacro.tex}.
\subsubsection{Files loaded with \texttt{\char92 usepackage}}
As far as I know, \LaTeX{} reacts to the construct
\verb+\usepackage{+\textit{name}\verb+}+ by loading the file
\textit{name}\texttt{.sty}.
\hevea{} reacts in a similar, but different, manner, by
loading the file \textit{name}\texttt{.hva}.
\hevea{} distributions already includes quite a few ``\texttt{.hva}''
implementations of famous packages (see section~\ref{implemented:package}).
When a given package (say \texttt{zorglub}) is not implemented, the
situation may not be as bad as it may seem first.
Hopefully, you are only using a few commands from package
\texttt{zorglub}, and you feel confident enough to implement
them yourself.
Then, it suffices to put your definitions in file~\texttt{zorglub.hva}
and \hevea{} will react to \verb+\usepackage{zorglub}+ by loading
\texttt{zorglub.hva}.
See section~\ref{usepackage} for the full story on \verb+\usepackage+.
\section{A note on style}
\subsection{Spacing, Paragraphs}
Spacing in the \html{} document reflects the original source spacing.
More precisely, any sequence of spaces is outputed as one
space, whereas a single newline is replicated in the output.
However one blank line (i.e., two newlines in a row) or more
introduce a paragraph break.
\index{tabulation}Whether the tabulation character is a space or not
is random, so avoid tabs in your source document.
Paragraphs are rendered by a blank line and there is no paragraph
indentation.
\hevea{} is a bit simplistic in breaking paragraphs and extra paragraph
breaks may be present in the final \html{} documents.
This can usually be corrected by modifying the source, without
altering \LaTeX{} output. For instance, some blank line before or
after a comment or macro definition can be deleted.
\index{ @`` '' (space)!after macro}
Space after macros with no argument is skipped (as in \LaTeX{}) ---
however this is not true in math mode, as explained in
section~\ref{spacemath} below.
Consider the following example:
\begin{verbatim}
\newcommand{\open}{(}
\newcommand{\close}{)}
\open text opened by ``\verb+\open+''
and closed by ``\verb+\close+''\close.
\end{verbatim}
We get:
\begin{htmlout}
\newcommand{\open}{(}
\newcommand{\close}{)}
\open text opened by ``\verb+\open+'' and closed by
``\verb+\close+''\close.
\end{htmlout}
In the output above, the space after \verb+\open+ does not
find its way to the output.
More generally,
\hevea{} tries to emulate \LaTeX{} behavior in all situations, but
discrepancies probably exist.
Thus, users are invited to make explicit what they want.
This is good practice anyway, because \LaTeX{} is mysterious
here. Consider the following example, where the \verb+\tryspace+
macro is first applied and then expansed by hand:
\begin{verbatim}
\newcommand{\bfsymbol}{\textbf{symbol}}
\newcommand{\tryspace}[1]{#1 XXX}
Some space: \tryspace{\bfsymbol}\\
No space: \bfsymbol XXX
\end{verbatim}
Spacing is a bit chaotic here,
the space after \textbf{symbol} remains when \verb+#1+ is substituted for it
by \LaTeX{} (or \hevea).
\begin{htmlout}
\newcommand{\bfsymbol}{\textbf{symbol}}
\newcommand{\tryspace}[1]{#1 XXX}
\begin{tabular}{l@{~:~}l}
Some space & \tryspace{\bfsymbol}\\
No space & \bfsymbol XXX
\end{tabular}%
%BEGIN LATEX
\par ~\vspace{-1ex}
%END LATEX
\end{htmlout}
Note that, if a space before ``XXX'' is wanted, then
one should probably write:
\begin{verbatim}
\newcommand{\tryspace}[1]{#1{} XXX}
\end{verbatim}
\subsection{Math mode}
\hevea{} math mode is not very far from normal text mode, except that
all letters are shown in italics and that space after macros
is echoed.
However, typesetting math formulas in \html{} rises two difficulties.
First, formulas contain symbols, such as Greek letters; second,
even simple formulas do not follow the simple basic typesetting model of~\html.
\subsubsection{Spacing in math mode}\label{spacemath}
\index{ @`` '' (space)!after macro!in math}
By contrast with \LaTeX{}, spaces from the input are significant in
math mode, this
feature allows users to instruct \hevea{}
on how to put space in their formulas.
For instance, \verb+\alpha\rightarrow\beta+ is typeset without spaces between
symbols, whereas \verb+\alpha \rightarrow \beta+ produces these spaces.
\begin{htmlonly}
$$
\begin{array}{l@{ : }l}
\verb+\alpha\rightarrow\beta+ & \alpha\rightarrow\beta\\
\verb+\alpha \rightarrow \beta+ & \alpha \rightarrow \beta\\
\end{array}
$$
\end{htmlonly}
Note that \LaTeX{} ignores spaces in math mode, so that users can
freely adjust \hevea{} output without changing anything to \LaTeX{}
output.
\subsubsection{Symbols}\label{symbols}
\begin{figure}[ht]
\caption{\label{symbol:fig}Some symbols}
\def\zyva#1{\texttt{\char92{}#1}:\quad & \Large $\csname#1\endcsname$}
\begin{center}
\begin{tabular}{rl@{\qquad}rl}
\zyva{in} & \zyva{notin}\\
\zyva{int} & \zyva{prod}\\
\zyva{preceq} & \zyva{prec}\\
\zyva{leq} & \zyva{geq}\\
\zyva{cup} & \zyva{cap}\\
\zyva{supset} & \zyva{subset}\\
\zyva{supseteq} & \zyva{subseteq}\\
\end{tabular}
\end{center}
\end{figure}
With respect to previous versions of~\hevea{} since the begining, the
treatment of symbols has significantly evolved. Outputting symbols is
now performed by using Unicode character references, an option that
much more complies whith standards than the previous option of
selecting a ``symbol'' font. Observe that this choice is now
possible, because more and more browsers correctly display such
references. See~Figure~\ref{symbol:fig} for a few such symbols.
However, this means that ancient or purposely limited browsers (such as
text-oriented browsers) cannot display maths, as translated by \hevea.
For authors that insist on avoiding symbols that cannot be shown
by any browser, \hevea{} offers a degraded mode that outputs text
in place of symbols.
\hevea{} operates in this mode when given the \texttt{-textsymbols}
command-line option. Replacement text is in English.
For instance. the ``$\in$'' symbol is replace by ``in''.
This is far from being satisfactory, but degraded mode may be
appropriate for documents than contain few symbols.
\subsubsection{Displays}
Apart from containing symbols, formulas specify strong typesetting
constraints: sub-elements must be combined together following patterns
that departs from normal text typesetting. For instance, fractions
numerators and denominators must be placed one above the other.
\hevea{} handles such constraints in display mode only.
The main two operating modes of \hevea{} are \emph{text} mode and
\emph{display} mode.
Text mode is the mode for typesetting normal text,
when in this mode, text items are echoed one following the other and
paragraph breaks are just blank lines, both in input and output.
The so called \emph{displayed-paragraph environments} of \LaTeX{} (such as
\texttt{center} or \texttt{quote}) are rendered by \html{} block-level
elements (such as \texttt{DIV} or \texttt{BLOCKQUOTE}).
Rendering is correct becauses both \LaTeX{} displayed environments and
\html{} block-level elements start a new line.
Conversly, since opening a \html{} block-level elements means starting
a new line, any text that sould appear inside a paragraph must be
translated using only \html{} text-level elements.
\hevea{} chooses to translate in-text formulas that way.
\hevea{} display mode allows more control on text placement, since
entering display mode means opening
a \html{} \verb+TABLE+ element and that tables allow to control the
relative position of their sub-elements.
Displays come in two flavor, horizontal displays and vertical
displays.
An horizontal display is a one-row table, while a vertical display is
a one-column table. These tables holds display sub-elements, displays
sub-elements being centered vertically in horizontal display mode and
horizontally in vertical display mode.
Display mode is first opened by opening a \verb+displaymath+ environment
(e.g. by \verb+$$+
or \verb+\[+).
Then, sub-displays are opened by \LaTeX{} constructs which require
them.
For instance, a displayed fraction (\verb+\frac+) opens a vertical display.
The distinction between text and display modes clearly appears while
typesetting math formulas.
An in-text formula such as
\verb+$\int_1^2 xdx = \frac{3}{2}$+ appears as:
%HEVEA$\int_1^2 xdx =\frac{3}{2}$,
%BEGIN LATEX
\raisebox{-1ex}{\image{int}},
%END LATEX
while the same formula has a better aspect in display mode:
%HEVEA$$\int_1^2xdx = \frac{3}{2}$$
%BEGIN LATEX
\begin{center}
\image{intd}
\end{center}
%END LATEX
As a consequence, \hevea{} is more powerful in display mode and
formulas should be displayed as soon as they get a bit complicated.
This rule is also true in \LaTeX{} but it is more strict in \hevea{},
since \html{} capabilities to typeset formulas inside text are quite
poor.
In particular, it is not possible to get in-text ``real'' fractions or
in-text limit-like subscripts.
Users should remember that \hevea{} is not \TeX{} or \LaTeX{} and that
\hevea{} author neither is D.~E.~Knuth nor L.~Lamport.
Thus, some formulas may be rendered poorly.
For instance, two fractions with different denominator and numerator
height look strange.
\begin{htmlonly}
$$
\frac{1}{\sum_{i=0}^{N}U_i} = \frac{\sum_{i=0}^{N}U_i}{1}
$$
\end{htmlonly}
%BEGIN LATEX
\begin{center}
\image{cloche}
\end{center}
%END LATEX
The reason is that vertical displays in an horizontal display are
\html{} tables
that always get centered in the vertical direction.
Such a crude model cannot faithfully emulate any \TeX{} box placement.
Users can get an idea on how \hevea{} combines elements in display mode
by giving the \verb+-v+ option comand line option twice, which
instructs \hevea{} to add a
border to the \verb+TABLE+ elements introduced by displays.
\subsubsection{Arrays and display mode}
By contrast with formulas, which \hevea{} attempts to render with
text-level elements only when they appear inside paragraphs, \LaTeX{} arrays
always translate to the
block-level element \verb+TABLE+, thereby introducing non-desired line
breaks before and after in-text arrays.
As a consequence, in-text arrays yield an acceptable output, only while
alone in a paragraph.
\begin{htmlonly}
Consider the following source:
\begin{verbatim}
This is a small array:
\begin{tabular}{|cc|}
\hline item-1 & item-2 \\
\hline\end{tabular}. Next sentence.
\end{verbatim}
We get:
\begin{htmlout}
This is a small array:
\begin{tabular}{|cc|}\hline item-1 & item-2
\\ \hline\end{tabular}. Next sentence.
\end{htmlout}
\end{htmlonly}
However, since in some sense, all \html{} tables are displayed, the
\verb+array+ and \verb+tabular+ environments implicitly open display
mode, thus allowing a satisfactory typesetting of formulas in
arrays. More precisely, array elements whose column format
specification is \verb+l+, \verb+c+ or \verb+r+ are typeset in display
mode (see section~\ref{arraydef}).
\subsection{Warnings}
When \hevea{} thinks it cannot translate a symbol or construct
properly, it issues a warning. This draws user attention onto a
potential problem. However, rendering may be correct.
\begin{htmlonly}
In the following (silly) example, \hevea{} gets nervous because of
the complicated length given as argument to \verb+\hspace+:
\begin{verbatim}
\newlength{\mylength}\setlength{\mylength}{5pt}
\begin{tabular}{c@{\hspace{\mylength}}c}
Before & After
\end{tabular}
\end{verbatim}
Running \hevea{} on this input produces a warning:
\begin{verbatim}
# hevea manual.tex
...
manual.tex:507: Warning: \hspace with arg ``\mylength''
...
\end{verbatim}
However the final rendering is correct:
\begin{htmlout}
\newlength{\mylength}\setlength{\mylength}{5pt}
\begin{tabular}{c@{\hspace{\mylength}}c}
Before & After
\end{tabular}
\end{htmlout}
\end{htmlonly}
Note that all warnings can be suppressed with the \verb+-s+ (silent)
option.
When a warning reveals a real problem, it can often be cured by
writing a specific macro. The next two sections introduce \hevea{}
macros, then section~\ref{trouble} describes how to proceed with
greater detail.
\subsection{Commands}
Just like \LaTeX{}, \hevea{} can be seen as a macro language, macros
are rewritten until no more expansion is possible. Then, either some
characters (such as letters, integers\ldots) are outputed or some
internal operation (such as changing font attributes, or arranging
text items in a certain manner) are performed.
This scheme favors easy extension of program capabilities
by users. However, predicting program behavior and correcting errors
may prove difficult, since final output or errors
may occur after several levels of macro expansion.
As a consequence, users can tailor \hevea{} to their needs, but it
remains a subtle task.
Nevertheless, happy \LaTeX{} users should enjoy customizing
\hevea{}, since this is done by writing \LaTeX{} code.
\subsection{Style choices}\label{stylechoice}
\LaTeX{} and {\html} differ in many aspects. For instance, \LaTeX{} allows
fine control over text placement, whereas
{\html} does not.
More symbols and font attributes are available in \LaTeX{} than in
{\html}. Conversely, {\html} has font attributes, such as color, which
standard \LaTeX{} has not.
Therefore, there are many situations where \hevea{} just cannot
render the visual effect of \LaTeX{} constructions. Here some choices
have to be made. For instance, calligraphic letters (\verb+\mathcal+)
are rendered in red (\verb+<FONT COLOR=red>+).
If you are not satisfied with \hevea{} rendering of text style
declarations, then you
can choose your own, by redefining the \verb+\cal+
macros, using \verb+\renewcommand+, the macro redefinition operator of
\LaTeX{}. The key point is that you need not worry about \hevea{}
internals: just redefine the old-\LaTeX{} style text-style
declarations (i.e. \verb+\it+, \verb+\sc+, etc.) and everything should
get fine:
\begin{verbatim}
\renewcommand{\sc}{\Huge}
\renewcommand{\cal}{\em}
\end{verbatim}
(See sections~\ref{trouble} and~\ref{both} on how to make such
changes while leaving your file processable by \LaTeX{}, and
section~\ref{customize-style} for a more thourough descriton of
customizing type styles).
\begin{htmlonly}
With such redefinitions, we get:
\renewcommand{\sc}{\Huge}
\renewcommand{\cal}{\em}
\begin{htmlout}
This is \textsc{small caps} and this is $\cal CALLIGRAPHIC LETTERS$
\end{htmlout}
\end{htmlonly}
Note that many of \LaTeX{} commands and environments are defined in the
\texttt{hevea.hva} file that \hevea{} loads before processing any
input.
These constructs are written using \LaTeX{} source code, in the end they
invoke \hevea{} internal commands.
Other \LaTeX{} constructs, such as
\LaTeX{} key constructs or \hevea{} internal commands (see section~\ref{internal}),
that require special processing are defined
in \hevea{} source code.
However, the vast majority of these definitions can be overridden by a
redefinition.
This may prove useless, since there is little point in
redefining core constructs such as \verb+\newcommand+ for instance.
\section{How to detect and correct errors}\label{trouble}
Most of the problems that occur during the translation of a given
\LaTeX{} file (say \verb+trouble.tex+) can be detected and solved at
the macro-level. That is, most problems induce a macro-related warning
and can be solved by writing a few
macros. The best place for these macros is an user style file (say
\texttt{trouble.hva}) given as
argument to \hevea.
\begin{verbatim}
# hevea trouble.hva trouble.tex
\end{verbatim}
By doing so, the macros written specially for \hevea{} are not
seen by \LaTeX. Even better, \verb+trouble.tex+ is not changed
at all.
Of course, this will be easier if the \LaTeX{} source is written in a
generic style, using macros.
Note that this style is recommended anyway, since it facilitates the changing
and tuning of documents.
\subsection{\hevea{} does not know a macro}\label{dontknow}
Consider the following \LaTeX{} source excerpt:
\begin{verbatim}
You can \raisebox{.6ex}{\em raise} text.
\end{verbatim}
\LaTeX{} typesets this as follows:
\begin{htmlout}
\begin{showlatex}
You can \raisebox{.6ex}{\em raise} text.
\end{showlatex}
\end{htmlout}
Since \hevea{} does not know about \verb+\raisebox+,
it incorrectly processes this input. More precisely,
it first prints a warning message:
\begin{verbatim}
trouble.tex:34: Unknown macro: \raisebox
\end{verbatim}
Then, it goes on by translating the arguments of \verb+\raisebox+ as if
they were normal text. As a
consequence some \verb+.6ex+ is finally found in the {\html} output:
\begin{htmlout}
You can .6ex{\em raise} text.
\end{htmlout}
To correct this, you should provide a macro that has more or less the effect of
\verb+\raisebox+. It is impossible to write a generic
\verb+\raisebox+ macro for \hevea, because of \html{} limitations.
However, in this case, the effect
of \verb+\raisebox+ is to raise the box {\em a little}.
Thus, the first, numerical, argument to \verb+\raisebox+ can be
ignored in a private \verb+\raisebox+ macro defined in \texttt{trouble.hva}:
\begin{verbatim}
\newcommand{\raisebox}[2]{$^{\mbox{#2}}$}
\end{verbatim}
Now, translating the document yields:
\begin{htmlout}
\renewcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
You can \raisebox{.6ex}{\em raise} text a little.
\end{htmlout}
Of course, this will work only when all \verb+\raisebox+ commands in
the document raise text a little. Consider, the following
example, where text
is both raised a lowered a little:
\begin{verbatim}
You can \raisebox{.6ex}{\em raise}
or \raisebox{-.6ex}{\em lower} text.
\end{verbatim}
Which \LaTeX{} renders as follows:
\begin{htmlout}
\begin{showlatex}
You can \raisebox{.6ex}{\em raise} or \raisebox{-.6ex}{\em lower} text.
\end{showlatex}
\end{htmlout}
Whereas, with the above definition of \verb+\raisebox+, \hevea{} produces:
\begin{htmlout}
\renewcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
You can \raisebox{.6ex}{\em raise}
or \raisebox{-.6ex}{\em lower} text.
\end{htmlout}
A solution is to add a new macro definition in the \verb+trouble.hva+ file:
\begin{verbatim}
\newcommand{\lowerbox}[2]{$_{\mbox{#2}}$}
\end{verbatim}
Then, \verb+trouble.tex+ itself has to be modified a little.
\begin{verbatim}
You can \raisebox{.6ex}{\em raise}
or \lowerbox{-.6ex}{\em lower} text.
\end{verbatim}
\hevea{} now produces a satisfying output:
\begin{htmlout}
\renewcommand{\raisebox}[2]{$^{\mbox{#2}}$}%
\newcommand{\lowerbox}[2]{$_{\mbox{#2}}$}
You can \raisebox{.6ex}{\em raise}
or \lowerbox{-.6ex}{\em lower} text.
\end{htmlout}
Note that, for the document to remain \LaTeX{}-processable,
it should also contain the following definition for
\verb+\lowerbox+:
\begin{verbatim}
\newcommand{\lowerbox}[2]{\raisebox{#1}{#2}}
\end{verbatim}
This definition can safely be placed anywhere in \texttt{trouble.tex},
since by \hevea{} semantics for \verb+\newcommand+ (see
section~\ref{usermacro})
the new definition will not overwrite the old one.
\subsection{\hevea{} incorrectly interprets a macro}\label{blob}
Sometimes \hevea{} knows about a macro, but the produced \html{}
does not look good when seen through a browser.
This kind of errors is detected while visually checking the
output.
However, \hevea{} does its best to issue warnings when such situations
are likely to occur.
Consider, for instance, this definition of \verb+\blob+ as a small
black square.
\begin{verbatim}
\newcommand{\blob}{\rule[.2ex]{1ex}{1ex}}
\blob\ Blob \blob
\end{verbatim}
Which \LaTeX{} typesets as follows:
\begin{latexout}
%BEGIN IMAGE
\begingroup\newcommand{\blob}{\rule[.2ex]{1ex}{1ex}}
\blob\ Blob \blob
\endgroup
%END IMAGE
%HEVEA\imageflush%
\end{latexout}
\hevea{} always translates \verb+\rule+ as \verb+<HR>+, ignoring size
arguments.
Hence, it produces the following, wrong, output:
\begin{htmlout}\newcommand{\blob}{\rule[.2ex]{1ex}{1ex}}
\begin{htmlonly}
\blob\ Blob \blob
\end{htmlonly}
\begin{latexonly}\vspace*{.5ex}
\image{blob}%
\end{latexonly}%
\end{htmlout}
We may not be particularily commited to a square blob.
In that case, other small symbols would perfectly do the job
of \verb+\blob+, such as a bullet (\verb+\bullet+).
Thus, you may choose to give \verb+\blob+ a definition in
\verb+trouble.hva+:
\begin{verbatim}
\newcommand{\blob}{\bullet}
\end{verbatim}
This new definition yields the following, more satisfying output:
\begin{htmlout}\newcommand{\blob}{\bullet}%
\begin{htmlonly}%
\blob\ Blob \blob
\end{htmlonly}
\begin{latexonly}\vspace*{.5ex}
\image{blob2}%
\end{latexonly}%
\end{htmlout}
\label{square:blob}
In case we do want a square blob, there are two alternatives.
We can have \LaTeX{} typeset some subparts of
the document and then to include them as images, section~\ref{imagen}
explain how to proceed.
We can also find a square blob somewhere in the variety of Unicode I
mean ISO~10646) characters,
and define \verb+\blob+ as a (numerical or symbolic)
character reference. Here, the character \texttt{U02588}
seems ok.
\begin{verbatim}
\newcommand{\blob}{\@print{█}
\end{verbatim}
\begin{htmlout}%
\begin{htmlonly}\newcommand{\blob}{\@print{█}}%
\blob\ Blob \blob
\end{htmlonly}
\begin{latexonly}\vspace*{.5ex}
\image{blob3}%
\end{latexonly}%
\end{htmlout}
However, beware that not all browsers display all of Unicode\ldots
\subsection{\hevea{} crashes}
\hevea{} failure may have many causes, including a bug.
However, it may also stem from a wrong \LaTeX{} input.
Thus, this section is to be read before reporting a bug\ldots
\subsubsection{Simple cases: \LaTeX{} also crashes}
In the following source, environments are not properly balanced:
\begin{verbatim}
\begin{flushright}
\begin{quote}
This is right-flushed quoted text.
\end{flushright}
\end{quote}
\end{verbatim}
Such a source will make both \LaTeX{} and \hevea{} choke.
\hevea{} issues the following error message that shows the \LaTeX{}
environment that is not closed properly:
\begin{verbatim}
trouble.tex:7: hml: DIV closes BLOCKQUOTE
trouble.tex:5: Latex environment ``quote'' is pending
Adios
\end{verbatim}
Thus, when \hevea{} crashes, it is a good idea to check that the
input is correct by running \LaTeX{} on it.
\subsubsection{Complicated cases}
Unfortunately, \hevea{} may crash on input that does not affect
\LaTeX.
Such errors usually relate to environment or group nesting.
Consider for instance the following ``optimized'' version of a
\verb+quoteright+ environment:
\begin{verbatim}
\newenvironment{quoteright}{\quote\flushright}{\endquote}
\begin{quoteright}
This a right-flushed quotation
\end{quoteright}
\end{verbatim}
The \verb+\quote+ and \verb+\flushright+ constructs
are intended to replace
\verb+\begin{quote}+ and \verb+\begin{flushright}+,
while \verb+\endquote+ stands for \verb+\end{quote}+.
Note that the closing \verb+\endflushright+
is omitted, since it does nothing.
\LaTeX{} accepts such an input and produces a right-flushed quotation.
However, \hevea{} usually translates \LaTeX{} environments to \html{}
block-level elements and it \emph{requires}
those elements to be nested properly.
Here, \verb+\quote+ translates to \verb+<BLOCKQUOTE>+,
\verb+\flushright+ translates to \verb+<DIV ALIGN=right>+ and
\verb+\endquote+ translates to \verb+</BLOCKQUOTE>+.
At that point, \hevea{} refuses to generate obviously
non-correct {\html} and it crashes:
\begin{verbatim}
trouble.tex:9: hml: BLOCKQUOTE closes DIV
trouble.tex:7: Latex environment ``quoteright'' is pending
Adios
\end{verbatim}
In this case, the solution is easy: environments must be opened and
closed consistently. \LaTeX{} style being recommended, one should write:
\begin{verbatim}
\newenvironment{quoteright}
{\begin{quote}\begin{flushright}}
{\end{flushright}\end{quote}}
\end{verbatim}
And we get:
\begin{htmlout}\newenvironment{quoteright}{\begin{quote}\begin{flushright}}{\end{flushright}\end{quote}}
\begin{htmlonly}
\begin{quoteright}
This is a right-flushed quotation
\end{quoteright}
\end{htmlonly}
%BEGIN LATEX
\image{rquote}
%END LATEX
\end{htmlout}
Unclosed \LaTeX{} groups (\verb+{+\ldots{}) are another source
of nuisance to \hevea{}.
Consider the following \texttt{horreur.tex} file:
\begin{verbatim}
\documentclass{article}
\begin{document}
In this sentence, a group is opened now {\em and never closed.
\end{document}
\end{verbatim}
\LaTeX{} accepts this file, although it produces a warning:
\begin{verbatim}
# latex horreur.tex
This is TeX, Version 3.14159 (Web2C 7.2)
...
(\end occurred inside a group at level 1)
Output written on horreur.dvi (1 page, 280 bytes).
\end{verbatim}
By contrast, running \hevea{} on \texttt{horreur.tex} yields a fatal error:
\begin{verbatim}
# hevea horreur.tex
horreur.tex:5: Latex env error: ``document'' closes ``''
horreur.tex:4: Latex environment ``'' is pending
Adios
\end{verbatim}
Thus, users should close opening braces where it belongs.
Note that \hevea{} error message ``\texttt{Latex environment
``}\textit{env}\texttt{'' is pending}'' helps a lot in locating
the brace that hurts.
\subsubsection{Desperate cases}