GNU TeXmacsUser manualReferenceAboutEnglish·Français·Deutsch·Español·Italiano
Converters for Html and MathML
Html generation

TeXmacs supports reasonably good converters to Html and MathML. A document can be exported to Html using File\(\rightarrow\)Export\(\rightarrow\)Html. TeXmacs makes moderate use of Css in order to improve the presentation of the generated Html.

The way in which mathematical formulas are exported is chosen using Edit\(\rightarrow\)Preferences\(\rightarrow\)Converters\(\rightarrow\)TeXmacs->Html\(\rightarrow\)Mathematical formulas:

Static SVG

Formulas are typeset by TeXmacs at the time of the export and written as Svg in the page, in the fonts of the document and in the environment where they are, together with their source, for importing the page back, and a hidden MathML version for screen readers. The page needs no scripts or web fonts.

MathJax

Formulas are written in LaTeX and typeset by the MathJax script when the page is read in a browser.

MathML

Formulas are exported as MathML. Notice that this requires you to save the generated documents using the .xhtml extension.

Images

This is the default. If your destination file is called name.html, then the images are stored in the same directory in files name-1.png, name-2.png and so on.

HTML tables

TeXmacs does its best in order to render formulas using existing Html/Css primitives.

Even when formulas are not exported as images, notice that all graphics drawn using TeXmacs are exported in this way. In particular, the exportation of a TeXmacs file with pictures may give rise to the creation of additional image files. You may also force arbitrary content to be exported as an image using Format\(\rightarrow\)Specific\(\rightarrow\)Image.

TeXmacs also provides a facility for the creation of entire websites. For this, you just have to regroup the files for your website into a single directory. Using Tools\(\rightarrow\)Web\(\rightarrow\)Create website you may now convert all TeXmacs files in this directory to Html files in a new directory. The conversion procedure recursively traverses all subdirectories and all non-TeXmacs files are simply copied.

Customized Html generation

The following TeXmacs environment variables can be used to customize the Html generation:

html-title

The title of your exported document.

html-css

A cascaded style sheet for your exported document.

html-head-javascript-src

An external Javascript file to be executed before the body.

html-head-javascript

A Javascript script to be executed before the body.

html-head-favicon

A “favicon” for your webpage.

You may also use the following macros:

<html-class|class|body>

<html-div-class|class|body>

Associate a CSS class to the content body, optionally inside a separate div tag.

<html-style|style|body>

<html-div-style|class|body>

Associate a CSS style to the content body, optionally inside a separate div tag.

<html-javascript-src|src>

Execute a Javascript script from the file src.

<html-javascript|code>

Execute the Javascript script code.

In addition, given a macro my-tag, you may customize the rendering of the tag when exporting to Html by defining a macro tmhtml-my-tag with the same number of arguments. For instance, by putting the declaration

<assign|tmhtml-strong|<macro|body|<with|color|red|font-series|bold|body>>>

inside your style file, all strong text will be exported to Html using a bold red font.

Html importation

TeXmacs also contains an input converter for Html/Mathml. Most of HTML 2.0 and parts of HTML 3.0 are currently supported, and standalone or embedded MathML are reasonably well supported. Entire Html and/or Mathml documents can be imported with File\(\rightarrow\)Import\(\rightarrow\)Html.

When importing HTML documents, files whose names start with http: or ftp: will be downloaded from the web using wget. If you compiled TeXmacs yourself, then you can download wget from

  ftp://ftp.gnu.org/pub/gnu/wget/

In the binary distributions, we have included wget.

With most web browsers, interesting fragments of a web page can easily be imported into TeXmacs without saving the page to a file: Using the browser's "inspect" contextual menu it is easy to spot the desired fragment in the xml tree, copy it, and then paste it into TeXmacs using Edit\(\rightarrow\)Paste from\(\rightarrow\)Html. When copying Mathml formulas, the entire <math> element should be selected. In some browsers, the "inspect" functionaly needs to be activated in the preferences.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".