|
NAMEtex2lyx - translate well-behaved LaTeX into LyXSYNOPSISThe 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 sfile1[,sfile2...]] [ -skipchildren ] [ -roundtrip ] [ -copyfiles ] inputfile [ outputfile ] OPTIONS
DESCRIPTIONIntroductiontex2lyx 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:
It achieves these main goals pretty well on most files. UsageHere's a more lengthy description of what you should do to translate a LaTeX document into LyX.
What tex2lyx Can Handletex2lyx understands many LaTeX commands. It will translate:
Some of this support may not be 100% yet. See below for details tex2lyx copies math (almost) verbatim from your LaTeX file. Luckily, LyX reads in LaTeX math, so (almost) any math which is supported by LyX should work just fine. tex2lyx will copy any preamble commands (i.e., anything before \begin{document}) verbatim. Fancy stuff you've got in your preamble should thus be conserved in printed documents, although it will not of course show up in the LyX window. Check Document->Settings->LaTeX Preamble to see the result. What tex2lyx Can't Handle --- But it's OK
tex2lyx copies unknown commands, along with their arguments, verbatim into the LyX file. Also, if it sees a \begin{foo} where it doesn't recognize the “foo” environment, it will copy verbatim until it sees \end{foo} (unless you use the -r option). Most of these unknown commands won't cause tex2lyx to break; they'll merely require you to do some editing once you've loaded the file up in LyX. That should be less painful than editing either the .tex or the .lyx file using a text editor. What tex2lyx Handles Badly --- aka BUGSSince tex2lyx is relatively new, it's got a number of problems. As it matures, these bugs will be squished.
All known bugs of tex2lyx can be found on http://www.lyx.org/trac/wiki/BugTrackerHome. tex2lyx is rather robust. As mentioned above, it may not translate your file perfectly, but the result should be usable and it shouldn't crash. If you encounter problems---and the problem is not one of those mentioned above or on http://www.lyx.org/trac/wiki/BugTrackerHome---please report the issue as described in the section on Bug Reports. What LyX Can't HandleLyX itself is missing a couple of features, such that even if tex2lyx translates things perfectly, LyX may still have trouble reading it. If you really need these features, you can export your final document as LaTeX, and put them back in. See BUGS for more details on these bugs.
EXAMPLEStex2lyx -f -r “myenv” foo.texThe above will create a file foo.lyx from foo.tex, overwriting if necessary. When it finds a \begin{myenv} ... \end{myenv} block, it will translate the stuff within the block, but copy the \begin and \end commands in TeX mode. tex2lyx -n -c “literate-article” foo.tex The above will change a noweb document into a LyX literate-article document. A user would do this if the noweb document had documentclass article. NOTESBug ReportsBugs should be reported to the LyX bug tracker at http://www.lyx.org/trac/wiki/BugTrackerHome. Additionally, you can post a message to the LyX developers' mailing list. Its address is currently lyx-devel@lists.lyx.org. If your message bounces, you can check the LyX home page, http://www.lyx.org/. If you are running tex2lyx on a huge file, please do not send all of the output in your bug report. Just include the last ten or twenty lines of output, along with the piece of the LaTeX file it crashed on. Or, even better, attach a small but complete file which causes the same problem as your original file.Layout Filestex2lyx reads a LyX layout file to know how to handle LaTeX environments and commands which get translated to LyX layouts. This file will include all “normal” non-math environments (i.e., including quote and itemize, but not tabular, minipage, and some other fancy environments), and commands like \section and \title. If you want to tex2lyx a class that doesn't have an existing layout file, then you'll have to create a layout file. But you have to do this anyway, in order to LyX the file, since LyX depends on layout files to know how to display and process its files. Check the LyX documentation for help with this task (which can be hard or easy, depending on the class you want to create a layout file for.) If your class is quite similar to a class that has a layout file, then consider using the -c option.Syntax Filestex2lyx always reads at least one syntax file, called the default syntax file. tex2lyx will read your personal syntax file if it exists; otherwise it will read the system-wide file. tex2lyx will read additional syntax files if you specify them with the -s option. (These extra files should have the same format as the default file, but will tend to be shorter, since they only have to specify extra commands not found in the default file.) A syntax file tells tex2lyx a few things.First, it describes the syntax of each command, that is, how many required arguments and how many optional arguments the command takes. Knowing this makes it easier for tex2lyx to copy (in TeX mode) commands that it doesn't know how to translate. The syntax file simply has a command, followed by braces or brackets describing its arguments in the correct order. For example, a syntax file entry \bibitem[]{} means that the \bibitem command takes an optional argument followed by a required one, while the entry \bf means that the \bf command takes no arguments at all. When tex2lyx encounters a token that it doesn't know how to translate into LyX, it will copy the token---along with the correct number of arguments---exactly. If the token is not in the syntax file, then tex2lyx just copies as many arguments as it finds. This means that it may copy too much. But since the user can specify additional syntax files, that shouldn't happen often. Some commands that cannot be translated to LyX, like \mbox, have as one of their arguments regular LaTeX text. If the string “translate” is put into an argument of an (untranslatable) command in the syntax file, then tex2lyx will translate that argument instead of copying it verbatim. So, for example, the default syntax file has \raisebox{}[][]{translate}. This means that the \raisebox command and the first argument (and optional arguments if they exist) are copied in TeX mode, but the last argument (which may contain math, complicated LaTeX, other untranslatable commands, etc.) will be translated into LyX. You can't use “translate” on optional arguments. User-defined syntax files are allowed to define new commands and their syntax, or override the number of arguments for a command given in the default syntax file. (E.g., if you're using a style that gives an extra argument to some command...) However, this will only be useful for commands copied in TeX mode. Commands which are actually translated by tex2lyx (like \item) have their argument syntax hard-coded. The hard-coded commands are identified in the default syntax file. Second, the syntax file describes any “regular environments”. Usually, an entire unknown environment will be copied in TeX mode. If you define a regular environment “foo”, though, then only the \begin{foo} and \end{foo} commands will be copied in TeX mode; the text within the environment will be treated (i.e., translated) by tex2lyx as regular LaTeX, rather than being copied into TeX mode. Don't try to declare “tabbing” and “picture” as regular environments, as the text within those environments will confuse tex2lyx; use this capability for new environments you create that have plain text or math or simple commands in them. You also can't declare unknown math environments (like equation*) as regular environments, either, since the LyX math editor won't understand them. The names of regular environments appear, whitespace-separated, between \begin{tex2lyxre} and \end{tex2lyxre} statements in the syntax file. (If you have a regular environment which you won't use very often, you can use the -r option rather than writing a syntax file.) WARNINGSAlways keep a copy of your original LaTeX files either under a different name or in a different directory. There are a couple ways in which using LyX could lead to overwriting the original LaTeX file.If you import foo.tex to create foo.lyx, then edit foo.lyx and want to re-export it, note that it will overwrite the original foo.tex. (LyX will ask you if you want to overwrite it.) ENVIRONMENT
The system directory is determined by searching for the file
"chkconfig.ltx". Directories are searched in this order:
The user directory is, in order of precedence:
FILESIf LIBDIR is the system-wide LyX directory and MY_LYXDIR is your personal LyX directory, then the following files are read by tex2lyx:
SEE ALSOlyx(1), latex(1)AUTHORStex2lyx is Copyright (c) 2003ff. by the LyX Team (lyx-devel@lists.lyx.org)
Visit the GSP FreeBSD Man Page Interface. |