You are on Eric Chopin's web site (Home)

LaTeX4Web 1.2 Manual

This page does not explain the TeX or LaTeX concepts, but rather give a quick tutorial of how to use the LaTeX4Web javascript, which will be easier to understand if you know already some basics about LaTeX of course.

The purpose of this script is to build web pages from some latex source. I have focused essentially on mathematical formulas and cross references. All the commands that are used for the page setup, styles, redefinition of commands etc are not managed by the script. The script produces no images, only a pure HTML page that can be seen on any browser and on any operating system in principle. It has been tested on IE4 and IE6 successfully. Since it is a script, It has the great advantage compared to other similar softwares that you can easily change what you want in it. You can change for instance some parts of the generated HTML code or even the way some latex commands are processed.

Basically, the script uses a Deterministic Finite Automata (DFA), or state machine, which can recognize a bit less than 200 keywords or token. This kind of programming technique is now commonly used for compilers or parsers, a lot of web sites explain how they work. You can add more token but then you must build a specific program to generate the files required by the DFA. They are latex_asc.js (the classes of characters used among keywords), latex_tok.js (an array of the keywords or tokens), latex_acc.js (the array of states, with non vanishing values when the states are "accepted", i.e. when the states correspond to a matched token inside the text to be parsed), and finally latex_dfa.js which contains the transition table. The transition table is a 1-dim array but it represents a 2-dim array, the size of which is the number of character classes times the number of states. Each entry tells you in which state you get when you are in a certain state and you encounter a certain character at the next position in the source text.

Most of commands that are not mathematics-related but rather cosmetic or cross-refs related use tricky regular expressions. It seems to be a rather good compromise on the performance point of view, since regular expressions use built-in functions in browsers, the only drwback beeing that you must parse the text completely for each regular expression you use. By comparison, the use of a DFA allows to parse the text only once whatever can be the number of tokens it is able to match. But the transition table grows dramatically when you increase the number of matching tokens...

If you often define some aliases in your latex files, using \def or \newcommand etc ... then you can possibly manage them within this javascript application. If there exist a regular expression that can transform your aliases into other managed latex commands or even directly into some html code, you can add your user defined replacements in the latex_aliases.js file. There are two functions in this file, one for replacements done before the DFA acts on the text, and one after.

You can add some HTML already within you latex source. The only constraint is that the html must not be within methamatical formulas, otherwise the characters < and > will be replaced by &lt; et &gt;, which will corrupt the HTML during the parsing. Elsewhere, your HTML code will be copied onto the output. If you insert images by adding <img src="MyFile.jpg"> within the source, avoid underscores in the filename, they will be badly interpreted.

Of course there must remain a lot of bugs. Feel free to send me an email for any suggestion or bug to report.

NOTES

LaTeX CommandSample usageHTML rendering
{...} { this is a test } this is a test
\bf { \bf this is a test } this is a test
\it {\it this is a test } this is a test
\small { \small \bf this is a test } this is a test
\large { \large this is a test } this is a test
\Large { \it \Large this is a test } this is a test
\huge { \huge this is a test } this is a test
Quoted text `` quoted text '' `` quoted text ¢¢
\par this is a test \par this is a new paragraph this is a test
this is a new paragraph
\\ (end of line) this is a test \\ this is a new paragraph
\begin{eqnarray}
x &=& 1 \\
y &=& 2 % no need of \\ on the last line
\end{eqnarray}
this is a test
this is a new paragraph
x
=
1     (0)
y
=
2     (1)
Special spaces \, \; \quad \qquad X\,this\;is\quad a\qquad test X this  is    a       test
Backslash followed by a space = space X\ Y X Y
Math mode $ .... $ $ e=mc^2 $ e=mc2
Centered math mode $$ .... $$ $$ e=mc^2 $$ e=mc2
Greek letters \alpha \beta \gamma ... $ \alpha + \beta + \ldots + \zeta $ a + b + ¼ + z
Variant of Greek letters \varphi \varepsilon \vartheta \varpi \varrho \varsigma $ \varphi + \varepsilon + \vartheta + \varpi - \varrho * \varsigma^2 $ j + e + J + v - r * V2
\ell (equiv to {\it l} ) \ell l
\aleph \aleph À
\i\i i
\j \j j
\wp \wp Ã
\re \re Â
\im \im Á
\partial \partial
\infty \infty ¥
\angle \angle Ð
\rangle \rangle ñ
\langle \langle á
\nabla \nabla Ñ
\Box $\Box \Phi + m^2\Phi = 0$ [¯] F + m2F = 0
\surd \surd Ö
\vert \vert |
\Vert \Vert ||
\rceil \rceil ù
\rfloor \rfloor û
\lceil \lceil é
\lfloor \lfloor ë
\{ \} \[ \] \{ \} \[ \] { } [ ]
\backslash \backslash \
\forall \forall "
\exists \exists $
\neg \neg Ø
\clubsuit \clubsuit §
\diamondsuit \diamondsuit ¨
\heartsuit \heartsuit ©
\spadesuit \spadesuit ª
\top \top T
\perp \perp ^
\circ \circ °
\~ \~ ~
\sim \sim ~
< ><font color=red > $ x < 2 $ </font> x < 2
~ (non breaking space) usage~: usage :
\ll \ll <<
\gg \gg >>
\star \star *
\diamond \diamond à
\bullet \bullet ·
\cdot \cdot ·
\cup \cup È
\cap \cap Ç
\pm \pm ±
\mp \mp -+
\vee \vee Ú
\wedge \wedge Ù
\oplus \oplus Å
\otimes \otimes Ä
\oslash \oslash Æ
\bigcap \bigcap Ç
\bigcup \bigcup È
\bigvee \bigvee Ú
\bigwedge \bigwedge Ù
\bigotimes \bigotimes Ä
\bigoplus \bigoplus Å
\subset \subset Ì
\subseteq \subseteq Í
\supset \supset É
\supseteq \supseteq Ê
\not\subset \not\subset Ë
\div \div ¸
\times \times ×
\lesim \lesim
\gesim \gesim
\mid \mid |
\leq \leq £
\geq \geq ³
\le\le £
\ge \ge ³
\equiv \equiv º
\approx \approx »
\neq \neq ¹
\in \in Î
\notin \notin Ï
\owns \owns '
\cong \cong @
\propto \propto µ
\leftarrow \leftarrow ¬
\rightarrow = \mapsto \rightarrow ®
\uparrow \uparrow ­
\downarrow \downarrow ¯
\leftrightarrow \leftrightarrow «
\Leftarrow \Leftarrow Ü
\Rightarrow \Rightarrow Þ
\Leftrightarrow \Leftrightarrow Û
\Uparrow \Uparrow Ý
\Downarrow \Downarrow ß
\ldots \ldots ¼
\vdots \vdots :
\ddots \ddots \
\dagger \dagger
\ddagger \ddagger
\lim \lim_{x\rightarrow 0} f=0 limx® 0 f=0
\overbrace \overbrace{ some text} Not yet implemented
\underbrace \underbrace{ some text} Not yet implemented
\overline \overline{A+\bar B} A+-B
\bar B+\bar A B+-A
\tilde \hat \hat B+\tilde x ^B+~x
Exponents and subscripts $ \sigma_0 + \lambda_\rho + \Phi_{\alpha=\beta} = a^7+a^\beta $ s0 + lr + Fa=b = a7+ab
vectors $ S = \vec X \cdot \vec Y $ S = ®X · ®Y
\over 1 \over 4 1/4
\frac{...}{....} \frac{p+q}{p-q}
p+q

p-q
Integrals in inline mode $ \Omega = \int_0^1 d\sigma + \int_\Sigma \omega + \int_{x=0}^{x=1-a} d\mu $ W = ò01 ds + òS w + òx=0x=1-a dm
Integrals in centered math mode \begin{equation} \Omega = \int_0^1 d\sigma + \int_\Sigma \omega + \int_{x=0}^{x=1-a} d\mu \end{equation}
W = ó
õ
1
0
ds + ó
õ
 
S
w + ó
õ
x=1-a
x=0
dm     (0)
Sums or prod in inline mode $\sum_{i=0}^N C_i^N + \prod_0^\Gamma a_i $ åi=0N CiN + Õ0G ai
Sums or prod in centered math mode $$\sum_{i=0}^N C_i^N + \prod_0^\Gamma a_i $$
N
å
i=0
CiN + G
Õ
0
ai
\lefteqn{ \begin{eqnarray}
\lefteqn{ x = } \\
&=& x(x+1) \\
&=& x^2+x
\end{eqnarray}
x =
= x(x+1)     (0)
= x2+x     (1)
\stackrel{\stackrel{\leftrightarrow}{\partial_\mu} «m
\begin{equation} ... \end{equation}\begin{equation}
\psi = e^{ikx+ \sqrt{\phi^2+1} } \label{toto}
\end{equation}
 
\begin{equation} e=mc^2 \end{equation}
y = eikx+ Öf2+1     (0)


e=mc2     (1)
\begin{array} ... \end{array} \begin{eqnarray}
\sigma & = & \left[\begin{array}{cc} 0 & 1 \\
1 & 0 \end{array}\right] \\
\lambda & = & \sigma^2
\end{eqnarray}
s
=
 
0
1
1
0
 
    (0)
l
=
s2
    (1)
\matrix{ .... } to be replaced? Not Yet Implemented
\begin{eqnarray} ... \end{eqnarray}\begin{eqnarray}
y &=& x(x+1) \\
&=& x^2+x
\end{eqnarray}
y = x(x+1)     (0)
= x2+x     (1)
\nonumber \nonumbersuppresses numbering of the current equation or equation line
\ref see eq \ref{toto}
 
\begin{equation}
\psi = e^{ikx+ \sqrt{\phi^2+1} } \label{toto}
\end{equation}
see eq (0)
y = eikx+ Öf2+1     (0)

Bibliography see in ref \cite{MyBook}

  \begin{thebibliography} \bibitem{MyResume} This is my resume
\bibitem{MyBook} Reference of my book \end{thebibliography}

see in ref [1]

 

  1. This is my resume
  2. Reference of my book
\section, \subsection, \subsubsection \section{Introduction}
blabla
\subsection{What is latex4web?}
blabla
\subsubsection*{The star skips automatic increase of section numbers}
blabla
\subsubsection{This is numbered}
...... blabla
\subsubsection{This one also}

blabla
\subsection{how to use the soft?}
blabla
\section{Next part}
...
\subsection{subsection of next part}

1 Introduction

blabla

1.1 What is latex4web?

blabla

The star skips automatic increase of section numbers

blabla

1.1.1 This is numbered

...... blabla

1.1.2 This one also

blabla

1.2 how to use the soft?

blabla

2 Next part

...

2.1 subsection of next part


Table Of Contents

1 Introduction

1.1 What is latex4web?

1.1.1 This is numbered

1.1.2 This one also

1.2 how to use the soft?

2 Next part

2.1 subsection of next part

\begin{itemize}...\item ... \end{itemize} \begin{itemize}
\item[-]{element1}
\item[*]{element2}
\item{element3}
\item element4
\end{itemize}

    - element1
    * element2
  • element3
  • element4