You are on Eric Chopin's web site (Home)
Maths
Lecture,LaTeX (fr)
Math Exam
Funny enigma (fr)
Physics
My Research
My PhD Thesis
Particle Physics at CERN (fr)
Computing
My Latex to HTML parser
Why Linux is better
M symbolic calculation software
Anti-Propaganda
Fight Spam actively
Homeopathy can be dangerous!!
Hoaxes in emails: chain letters, fake virus alerts,...
Fight neo nazi propaganda
Misc.
Contact Me

# 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

• Other latex commands are just considered as plain text.
• Avoid huge latex inputs. The program is written in javascript which is much slower than any other compiled language.
• By default the debug option is desactivated. To activate it, find in the source of the page the commented paragraph in which the debug string is built. Then, by clicking on the debug button, a new internet explorer window is open which contains information that is useful for debugging. Each token found is shown within the latex source code. Use this functionnality only with very small latex source!!
• On some versions of windows, the latex source cannot contain more than 65536 characters, because an input box on a web page cannot contain more characters. However, it is quite easy to add a simple vbscript in the page source such that the latex source is not read in the input box but rather in a separate text file. As well, the generated html code may be truncated in the output box for large outputs. However, in this case, just open the preview window ("Show" button) and get the full html code by opening the source code of this window (see in the menu "View\Source")
• Image inclusion using \epsfbox (for instance) is not supported, but you can easily add .jpg or .gif images just adding a tag <IMG src="MyImageFile.gif"> inside the latex source. The tag will be propagated "as is" in the HTML output. Note that you should avoid underscores in file names or in the attributes of HTML tags you add (at least until version 1.2 of the script), because they will be treated as subscripts like in math mode. This is corrected in v1.3
• For some commands that uses regular expressions and are followed by a group, like \centerline{...} \section*{}, do not nest subgroup inside the main group. The commands applies to the text following the next { character and ends at the first } character encountered.
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)
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 $$\Omega = \int_0^1 d\sigma + \int_\Sigma \omega + \int_{x=0}^{x=1-a} d\mu$$ 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
$$...$$
\psi = e^{ikx+ \sqrt{\phi^2+1} } \label{toto}

$$e=mc^2$$
 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

 l
 =
 s2
\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}

\psi = e^{ikx+ \sqrt{\phi^2+1} } \label{toto}

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]

\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}

blabla

blabla

blabla

...... blabla

blabla

blabla

...

# 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