GNU TeXmacsUser manualReferenceAboutEnglish
Converters for Word and OpenDocument

TeXmacs reads and writes the documents of Microsoft Word (.docx) and the texts of OpenDocument (.odt), the format of LibreOffice and OpenOffice. A file with one of these suffixes opens as a document, and a document is written with File\(\rightarrow\)Export\(\rightarrow\)Word or File\(\rightarrow\)Export\(\rightarrow\)OpenDocument and read with File\(\rightarrow\)Import. Nothing else is needed: the converters are part of TeXmacs.

The two formats are read into the same structure and written from it, so that what is said below holds for both.

What is kept

The converters keep the structure of a document, and the formatting which a reader would miss; they do not try to keep its look. A paragraph is what its style says: a paragraph with the style Heading 2 is a subsection, whatever its font is, and a text in a large bold font with the style of the body is a paragraph in bold.

Title

The paragraphs with the styles Title, Subtitle, Author, Date and Abstract at the start of a document are its title. (The title of the properties of the file is not shown: it is often the one of a template.)

Page and paragraphs

The size of the page, its orientation and its margins, and the usual paragraph of the document (the size of its font, a font without serifs, its alignment, the indentation of its first line, the spaces between its lines and around it) are the ones of the TeXmacs document, in both directions. A paragraph aligned otherwise keeps its alignment.

Headings

The levels of the headings are the sections, subsections and so on; a heading has a number when it has one in the file. A table of contents is the one of TeXmacs, which makes it again.

Text

Emphasized, strong, underlined and struck through text, subscripts and superscripts, small capitals, code (a font with a fixed width), colors and highlighting, links, line and page breaks.

Lists

With bullets or numbers (1, a, A, i, I), nested, with several paragraphs in an item, from their first number (a list of Word which goes on after a paragraph goes on with its numbers); the lists of terms and definitions.

Tables

With the borders and the backgrounds of their cells, the cells over several columns or rows, the alignments, the width of the table and of its columns when it has one, tables inside cells.

Mathematics

The formulas of both formats become formulas of TeXmacs which can be edited, and the other way round: the formulas which are written are those of the equation editors of Word and of LibreOffice. The conversion goes through MathML.

Images

The images are kept inside the document, with their sizes and the parts which are cut from them. A paragraph of images followed by a caption is a figure, and so for a table. The pictures of Windows (Emf, Wmf) which Word documents often have are made images by LibreOffice, when it is installed, and are a frame with their name else: all the pictures of a file are converted at once, a picture which is there several times once, and a LibreOffice which does not answer within two minutes is stopped. It has a profile of its own, in system/office-profile of the home directory of TeXmacs.

Drawings

A drawing made with TeXmacs is exported as a picture: an Svg image, which stays sharp at any size, with a bitmap of it for the programs which do not show Svg (the versions of TeXmacs without MuPDF write the bitmap only). An image in a format which the office programs do not read (Pdf, Postscript) is exported as a bitmap of what TeXmacs displays, and an Svg image as itself with its bitmap.

Notes

Footnotes and endnotes are footnotes.

Boxes of text and shapes

A box of text, or a shape (a rectangle, an ellipse…) with or without text, is shown as a framed box of its width with its fill, on its side, in a paragraph of its own before the paragraph which it belongs to; a shape without text is a drawing. Their text can be edited, and they are written back as boxes and shapes, in both directions. The shapes in groups and the other drawings give their text after their paragraph. A figure in a frame of LibreOffice, with its caption, is a figure. Hidden text is left out.

Quotations and code

From the styles Quote and Source Code (Quotations and Preformatted Text in OpenDocument).

The style office

A Word or OpenDocument file which is opened is a document of the style office, which keeps what the file says and the standard tags of TeXmacs do not, so that the file which is saved again is close to the one which was read:

Named styles

A paragraph or a piece of text of a named style of the file (Warning, Keyword) is office-par or office-span with the name of the style, which is shown as the file shows it (its font, size, color, alignment, indentation, spacing, background and border): the style is a macro office-par-name or office-span-name of the document, which can be edited. When the document is saved again in its format, a style whose macro was changed gets the properties which were changed (as bold, italic, the color, the size, the font, the alignment, the indentations, the spaces, the background, the border); its other properties are those of the file. The look of the headings is the one of the titles of the sections (section-title…), and the look of the title, the subtitle and the date at the start of the document is the one of the macros doc-title, doc-subtitle and doc-date of the document; they are not written back.

Headers and footers

They are the headers and footers of the pages of the document, with the number of the page; those of the first page are at the start of the text. A header or a footer which was changed in TeXmacs is written instead of the one of the file, as one paragraph, centered or on the right when it starts with a tab (and ends with one); one which was removed is not written. The others are those of the file, as they were.

Fields

A field (a page number, a date, the title of the document, a citation of Zotero) is office-field, which shows its result and keeps its instruction. A field inside the instruction of another one, as PAGE in IF { PAGE } = 3 "yes" "no", is an office-field inside the instruction, and is written as a field inside the field. The bibliography of Zotero in a Word file, which is several paragraphs, is a field too, so that Zotero can refresh it after the document is saved.

Comments and changes

A comment is office-comment, after its mark, with its author, and a comment on a range of the text of a paragraph is office-commented, with the text, which is marked, and the comment; the text which was inserted and the one which was deleted while the changes are tracked are office-ins and office-del, in color.

Columns

A section in several columns is office-columns, or office-columns* with the line between the columns (which TeXmacs does not draw) and the space between them.

Floating images

An image with the text around it is office-float, with its side, where it is and how the text goes around it: TeXmacs shows it in a paragraph of its own, before the paragraph which it belongs to. A box of text is office-box (with its side, the rest of where it is, its width, its fill, its line and its text), and a shape without text office-shape.

The file

The file itself is kept in the environment of the document (office-package), with the headers, the footers and the macros of the named styles as they were read (office-original): when it is saved again in its format, its named styles, its pages with their headers and footers, its fonts, its theme, its settings and its properties are written again (with what was changed in TeXmacs), and the text, its notes, comments and lists are those of TeXmacs. The parts of the file which nothing that is written names any more (a picture of a paragraph which was deleted, a header which was replaced) are not written, nor the small picture of its first page which Word files have.

Since the whole file is kept, a TeXmacs document of the style office, saved as a .tm file, also holds what was deleted from it in TeXmacs: the old text, comments and pictures, and the properties of the file (its author…). Send the Word or OpenDocument file which TeXmacs writes rather than the .tm file when that matters, or remove the variables office-package and office-original from the initial environment of the document (it is then written as a new file). Saved in the other format (a Word file as an OpenDocument file, or the reverse), the named styles are written with their look, taken from the macros office-par-name and office-span-name of the document, else from the file.

The option office->texmacs:faithful of the converter (on by default, in Edit\(\rightarrow\)Preferences, Convert, Office) makes these documents; without it, a file is a document of the style generic, with the look of the named styles of its text, the results of its fields and its changes accepted.

Exporting

The file which is written uses named styles for its paragraphs (Heading 1, Title, Caption, Quote, Theorem, Proof, Bibliography…), so that its look can be changed at once in Word or LibreOffice by changing these styles or by applying a template. Its text has a font with serifs (Times New Roman), or Arial for a document without serifs, and the size of the font of the document. Several lines of equations (eqnarray, align) are an array of equations of Word, all the screens of a presentation are written, each on a page of its own, and so is what is folded.

Numbers and references

The numbers of a document stay numbers in the office programs, which count them again when the document changes there (in Word, select all and press F9; in LibreOffice, Tools, Update, Fields). Update the document in TeXmacs first, with Document\(\rightarrow\)Update\(\rightarrow\)All: the numbers which are written are those which it displays.

Headings

The sections are numbered by the office program, as 1, 1.1, 1.1.1; a section without a number has none.

Theorems, figures, tables, equations

Their numbers are fields of a sequence (Theorem, Figure, Table, Equation). Theorems, proofs and the like are paragraphs with their name and number in bold, in the style Theorem, Remark or Proof; a figure or a table is followed by its caption.

References

A reference is a field which shows the number of its target, and follows it. The labels are bookmarks; in a Word file their names only have letters, digits and _ (thm:main is tm_thm_main).

Bibliography

The entries are paragraphs in the style Bibliography with numbers of the sequence Reference, and a citation is a reference to its entry.

A number is only written as a field when it is the next one of its sequence: with another way of numbering (by sections, as 2.1) it is written as it is, and the references to it show it as it is.

In the other direction, the paragraphs in the styles Theorem, Remark and Proof which start with an English name (Theorem, Lemma, Definition, Proof…) are the environments of TeXmacs, a formula with its number is a numbered equation, the paragraphs in the style Bibliography are a bibliography, and a reference whose text is the number of its target is a reference of TeXmacs. A document which was exported comes back with its numbers and its references.

Limitations
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".