tex2lyx (1) Linux Manual Page
NAME
tex2lyx – translate well-behaved LaTeX into LyX
SYNOPSIS
The simplest way to use tex2lyx is via the File->Import->LaTeX (plain) menu item in LyX. That runs tex2lyx on the given file and loads the resulting file into LyX. You should try that first, and call it from the command line only if you need to use more complicated options.
tex2lyx [ -userdir userdir ] [ -systemdir systemdir ] [ -f ] [ -n ] [ -c textclass ] [ -e encoding ] [ -fixedenc encoding ] [ -m module1[,module2…]] [ -s -skipchildren ] [ -roundtrip ] [ -copyfiles ] inputfile [ outputfile ]
OPTIONS
-c- Class. By default, when
tex2lyxsees a \documentclass{foo} command, it creates a file of textclass “foo” and reads the LyX layout file for that class (something like /usr/local/share/lyx/layouts/foo.layout ORHOME/.lyx/layouts/foo.layout). Use-cto declare a different textclass (and read a different layout file). - This option is needed if the input file is a LaTeX fragment, with no preamble matter or egin{document} command. LyX files created by
tex2lyxfrom partial files can be included in an existing LyX file using the “Include LyX File” command from LyX’s Insert menu. -m- Module. Load the given modules. This is useful if
tex2lyxdoes not automatically detect a given module, but you know the modules that provide some commands or environments that are used in the imported file. The modules are loaded in the given order. If a module foo depends on a module bar, bar must be given before foo. -f- Force.
tex2lyxwill not run if the .lyx file it would generate already exists. Use the-foption (carefully) to clobber any existing files. -e- Specify the default encoding using the LaTeX name as defined in the encodings file.
tex2lyxwill use this encoding, but switch if it finds any encoding changing commands in the input. -fixedenc- Specify the encoding using the LaTeX name as defined in the encodings file.
tex2lyxwill ignore any encoding changing commands in the input. -n- Noweb. Translate a noweb (aka literate programming) file. This should be (almost?) equivalent to running “noweb2lyx foo.tex foo.lyx”. This option requires the
-coption. -skipchildren- Do not translate child documents included via \include and \input. This option is useful if the child documents are generated files and/or contain many commands that
tex2lyxdoes not understand yet. -s- Syntax files. Input (one or more quoted, comma-separated) syntax files to read in addition to the default. (see the section on Syntax Files for details).
-sysdir- Specify a system directory. Normally, you shouldn’t need this. Your LyX system directory is chosen. Cf. the section FILES for details.
-userdir- Specify a user directory. Normally, you shouldn’t need this. Your LyX user directory is chosen. Cf. the section FILES for details.
-roundtrip- Call LyX to re-export the created output file to LaTeX. If the output file name is not given it is determined automatically to avoid over-writing the input file by accident: If the input file is named foo.tex the output file will be named foo.lyx.lyx, and the re-exported file will be named foo.lyx.tex.
-copyfiles- Copy all included files
tex2lyxis aware of to the output directory if the output file is located in a different directory than the input file. This is useful if you want to ensure that no included file is overwritten (either in roundtrip mode or by a later export from LyX). Please note that the resulting document may be uncompilable. This happens if it needs files thattex2lyxdoes not know about and therefore does not copy to the output directory. -help- Help. Print out usage information and quit.
-version- Print out the version number and build information and quit.
DESCRIPTION
Introduction
tex2lyx will create a LyX file with the specified name (or dir/foo.lyx if no name was given) from the LaTeX file dir/foo.tex.
Suffixes .tex, .ltx and .latex are supported. If inputfile does not exist and does not have one of these suffixes, tex2lyx will try to translate inputfile.tex. (This is similar to the behavior of LaTeX.)
The purpose of tex2lyx is to translate well-behaved LaTeX2e into LyX. If your LaTeX file doesn’t compile—or if you do weird things, like redefining standard LaTeX commands—it may choke. LaTeX209 will often be translated correctly, but it’s not guaranteed.
tex2lyx lacks a few features. However, its main goals are:
- •
- Get through a well-behaved LaTeX2e file without crashing
- •
- Translate a lot of that file.
- •
- Localize the parts that can’t be translated and copy them in TeX mode
It achieves these main goals pretty well on most files.
Usage
Here’s a more lengthy description of what you should do to translate a LaTeX document into LyX.
- •
- Run
tex2lyx. -
tex2lyxwill inform you of its progress and give any warnings to stderr, so if you don’t want any output at all, try (in csh) `tex2lyx foo.tex >& /dev/null’. You should NOT redirect standard output to foo.lyx. - •
- Run LyX (version 2.1 or later) on the resulting .lyx file.
- In theory, most of the file will have been translated, and anything that’s untranslatable will be transferred to TeX code (ERT in LyX-speak). In theory, LyX will be able to read in the file, and to create printed documents from it, because all that untranslated ERT stuff will be passed directly back to LaTeX, which LyX uses as a backend. Unfortunately, reality doesn’t always reflect theory. If
tex2lyxcrashes, or LyX cannot read the generated LyX file, see the BUGS section below. - •
- Transform things have been inserted as TeX code manually to LyX features, if possible.
- As mentioned above, you should be able to print out the LyX file even without doing this. However, changing a command in TeX code to the corresponding LyX object will allow you to take advantage of LyX’s WYSIWYM editing.
-
tex2lyxis not guaranteed to create a LyX file which generates exactly the same output as the LaTeX file, although its goal is to achieve this.tex2lyxwill generally err on the side of translating less to ensure that the resulting output files are accurate, even though this leads to more TeX code and less WYSIWYM. - •
- PROOFREAD THE DOCUMENT!!
- I’m sure you were planning on doing this anyway, but it’s particularly important after translating a LaTeX document.
tex2lyxis better at “macro-translating” (translating the whole document) than “micro-translating” (translating every little detail). For example, you may see extra spaces or deleted spaces. Space handling has improved, but it’s not perfect.
What tex2lyx Can Handle
tex2lyx understands many LaTeX commands. It will translate:
- •
- regular text, including mini-commands like ~, `’, \@, \TeX, as well as accented characters like \'{a}, and the special cases ?` and !`
- •
- title commands like uthor, \date, itle, hanks and the abstract environment
- •
- heading commands like \section including starred commands (\section*)
- •
- Environments: quote, quotation, and verse; center, flushright, and flushleft
- •
- itemize, enumerate, and description environments, and their \item commands. Also, well-behaved nested lists
- •
- cross-referencing commands:
ef, \pageref, \label, and
