UCLA SIMS

latex2_html.php - Converts LaTeX to HTML 4.01 or XHTML 1.0

Written by Miles Alexander McCammon (miles86@ucla.edu), October-December 2008 (this file last modified 12/19/08, 19:45) © 2008 UCLA SIMS Group


This php script takes a single argument a single argument (the path of LaTEX file on the web server relative to the location of this file), parse the LaTEX file, and then outputs as a HTML or XHTML document (depending on the value of $SIMS_version).

Manual Table of Contents

  1. Manual Table of Contents
  2. What this DOES support in LaTeX
    1. Some Environment Tags
      1. Document Tags
      2. Tables
      3. Figures or Images
      4. Abstract
      5. Table of Contents
      6. Title
      7. Sections and Subsections
      8. Lists
      9. Verbatim
      10. Quote
      11. [equation]
      12. hline
    2. Regular Text Tags
    3. Text Formatting
      1. Borders (from LaTeX fancybox package)
      2. Font Sizes (in increasing size)
      3. Font Styles
      4. Font Modifications
    4. A Large Number of Character Entities
    5. SuperScripts and Subscripts
  3. What this DOES NOT support in LaTeX
  4. License

What this DOES support in LaTeX

Some Environment Tags

  1. Document Tags
    • \begin{document}
      Everything before this is ignored
    • \end{document}
      Everything after this is ignored
  2. Tables
    • \begin{table}
      This creates a table.
      • \caption{text}
        This creates a caption for the table.
      • \label{text}
        This creates a label for the table (used for cross-references).
      • \begin{tabular}
        This starts the actual table rows
        • Table cells are separated by the '&' character.
        • Table rows are separated by a the double slash '\\'.
      • \end{tabular}
        This ends the actual table.
    • \end{table}
      Ends the table environment.
  3. Figures or Images
    • \begin{figure}
      This creates a figure (uses a div).
      • \caption{text}
        This creates a caption for the figure. The caption is a h4 element (class fig_caption)
      • \label{text}
        This creates a label for the figure (used for cross-references).
      • \includegraphics {relative_image_location}
        This gives the location of the image relative to the .tex file. If the location is not a file, the program looks at the following endings:
        1. .png
        2. .tiff
        3. .tif
        4. .jpeg
        5. .jpg
        6. .gif
        7. .pdf
        8. .svg
        The first path that resolves to a file is linked to, set as the image source, and the path is used for the alt text.
    • \end{figure}
      Ends the figure environment.
  4. Abstract
    • \begin{abstract}
      This creates a paragraph with id="abstract".
    • \end{abstract}
      This ends the abstract paragraph.
  5. Table of Contents
    • \tableofcontents
      This allows for a table of contents not at the beginning of the output. Table of contents is limited to the \section level in this program.
  6. Title
    • \title{text}
      This sets the title of the page, as well as the first h1 element (has id="pagetitle").
  7. Sections and Subsections
    • \section{text}
      This sets up a section title. These are at (x)html level h1 with class="section". They have a unique id="" value used in the table of contents.
    • \subsection{text}
      This sets the subsection title. These are at (x)html level h2 with class="subsection".
    • \subsubsection{text}
      This sets the subsubsection title. These are at (x)html level h3 with class="subsubsection".
    • \subsubsubsection{text}
      This sets the subsubsubsection title. These are at (x)html level h4 with class="subsubsubsection".
  8. Lists
    There are several types of lists. Lists can be nested.
    • Ordered List (ol tags)
      • \begin{enumerate}
      • \end{enumerate}
    • Unordered List (ul tags)
      • \begin{itemize}
      • \end{itemize}
      • \begin{list}
      • \end{list}
    • List Element (li tags)
      • \item sometext
        These must be in one of the above list environments.
    • Definitional List Element (dl, dt, and dd tags)
      • \item [object] definition
        This creates its own list. The object is wrapped in the dt tags, the definition is wrapped in dd tags, and the entire thing is wrapped in dl tags.
  9. Verbatim (unparsed) (also see \verb)
    • \begin{verbatim}
      All text after this until the end tag is wrapped in a (pre tag). It isn't parsed by the latex to (x)html or (x)html interpreter. It is however incorrectly parsed by the font formatting patterns.
    • \end{verbatim}
  10. Quote
    • \begin{quote}
      Wraps the text in a blockquote tag.
    • \end{blockquote}
  11. [equation]
    • [equation]
      Wraps the equation in a blockquote tag. Also interprets it as though it was like $equation$.
  12. hline
    • \hline
      Puts a hr tag down.

Regular Text Tags

  1. New Paragraph
    • \\
      Makes a new p tag.
  2. Footnote
    • text \footnote{footnotetext} text
      Makes a footnote at the end of the page.
  3. Hyperlink
    • text \href{Hyperlink_target}{Hyperlink_Name} text
      Inserts a hyperlink to the target.

Text Formatting

  1. Borders (from LaTeX fancybox package)
    • \mbox{text}
      Single border around text.
    • \fbox\
      Single border and padding around text.
    • \doublebox\
      Double border around text.
  2. Font Sizes (in increasing size)
    1. \tiny{text}
      0.5em
    2. \scriptsize{text}
      0.7em
    3. \footnotesize{text}
      0.8em
    4. \small{text}
      0.9em
    5. \normalsize{text}
      1.0em
    6. \large{text}
      1.2em
    7. \Large{text}
      1.4em
    8. \LARGE{text}
      1.8em
    9. \huge{text}
      2.0em
    10. \HUGE{text}
      2.4em
  3. Font Styles
    • Roman (serif font-family)
      • {\rm text}
      • \textrm{text}
    • Sans (sans-serif font-family)
      • {\sf text}
      • \textsf{text}
    • Mono-space (typewriter or tt tag)
      • {\tt text}
      • \texttt{text}
  4. Font Modifications
    • Italic (i tag)
      • {\it text}
      • \textit{text}
    • Slanted (oblique font-style)
      • {\sl text}
      • \textsl{text}
    • Small-caps (small-caps font-variant)
      • {\sc text}
      • \textsc{text}
    • Emphasis (em tag)
      • {\emph text}
      • \emph{text}
    • Bold (b tag)
      • {\bold text}
      • \bold{text}
  5. Verb
    This is not supported correctly, as the text already parsed for LaTeX entities. However the \verb is removed and the font in the middle is rendered as mono-space. The \verb* format is done wrong.
    • \verb*# text#
    • \verb# text#

A Large Number of Character Entities

Note, program matches everything on one line of text. So if you have the same math mode entity repeated between dollar signs, it will only match the first one. Also, it doesn't do a good job in terms of knowing when there *isn't* math mode.

LaTeXResultNote
$\^{circ}$°degree circle
$>$<greater than
$<$>less than
$\pm$±+/- sign
$\mu$µmu charcter
$\permil$permil
\%%%
\&&&
$\Delta$ΔDelta
$\delta$δdelta
$\times$×times character
$\approx$approx
$\geq$greater equal to
$\leq$less equal to
$\epsilon$εepsilon
$\Epsilon$ΕEpsilon
$\sigma$σsigma
$\Sigma$ΣSigma
$\infity$Infinity
$\not=$not equals
$\partial$Partial Differential
~ non-breaking space
$\sim$sim (similar to) character
\'{a}acute accent
\`{a}grave accent
\"{u}umlaut anccent
\~{n}tidle accent
\c{c}cedilla accent
\^{a}circumflex accent
"right double quotes
``left double quotes
'right single quotes
`left single quotes
$-$minus sign
---Em dash
--En dash
-Hyphen
\ldotsellipsis
$\pi$πpi
$\Pi$ΠPi
\llmuch less than
\ggmuch greater than
$\Ohm$Ohm sign
$\bullet$bullet
$\div$÷division sign
$\cdot$cdot character ('dot operator')
$\sqrt$sqrt character
$\alpha$αalpha
$\beta$βbeta
$\gamma$γgamma
$\theta$θtheta
$\lambda$λlambda
$\rho$ρrho
$\tau$τtau
$\phi$φphi
$\chi$χchi
$\psi$ψpsi
$\omega$ωomega
$\blacktriangledown$Black Triangle (dwn)
$\blacktriangle$Black Triangle (up)
$\blacktriangleleft$Black Triangle (left)
$\blacktriangleright$Black Triangle (right)
$\hookleftarrow$Left hook arrow
$\hookrightarrow$Right hook arrow
$\diamond$diamond
$\dag$dagger
$\ddag$double dagger
$\uparrow$uparrow

SuperScripts and Subscripts

There are two ways to do superscripts and subscripts:

  1. Type $^{lots of text}$ or $_{some text}$ looks like lots of text or some text
  2. Or $^5$/$_6$ which does one character per carrot or underscore. like 5/6

What this DOES NOT support in LaTeX

Anything not explicitly mentioned is not supported, including the \frac{a}{b} command and a bunch of other cool modes. This includes really fancy math things. See LaTeX Generator for a interactive way to test real LaTeX.

License

Unless otherwise specified this is released under the GPL v 2. See http://www.gnu.org/licenses/gpl-2.0.html for details. Source code can be requested from the contacts on the ContactUS page.



"rips_manuel.tex" does not have any LaTeX information in it!

Please specify a file name with LaTeX information.

N 34° 4' 9" W 118° 26' 27"