]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/tex2lyx.man
Patch from "hzluo" <memcache@gmail.com>:
[lyx.git] / src / tex2lyx / tex2lyx.man
1 .rn '' }`
2 ''' $RCSfile: tex2lyx.man,v $$Revision: 1.1 $$Date: 2005/07/16 15:18:14 $
3 '''
4 ''' $Log: tex2lyx.man,v $
5 ''' Revision 1.1  2005/07/16 15:18:14  larsbj
6 ''' drop reLyX like it is hot, and setup to use tex2lyx instead (and remerged po files + no.po small update)
7 '''
8 '''
9 .de Sh
10 .br
11 .if t .Sp
12 .ne 5
13 .PP
14 \fB\\$1\fR
15 .PP
16 ..
17 .de Sp
18 .if t .sp .5v
19 .if n .sp
20 ..
21 .de Ip
22 .br
23 .ie \\n(.$>=3 .ne \\$3
24 .el .ne 3
25 .IP "\\$1" \\$2
26 ..
27 .de Vb
28 .ft CW
29 .nf
30 .ne \\$1
31 ..
32 .de Ve
33 .ft R
34
35 .fi
36 ..
37 '''
38 '''
39 '''     Set up \*(-- to give an unbreakable dash;
40 '''     string Tr holds user defined translation string.
41 '''     Bell System Logo is used as a dummy character.
42 '''
43 .tr \(*W-|\(bv\*(Tr
44 .ie n \{\
45 .ds -- \(*W-
46 .ds PI pi
47 .if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
48 .if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
49 .ds L" ""
50 .ds R" ""
51 '''   \*(M", \*(S", \*(N" and \*(T" are the equivalent of
52 '''   \*(L" and \*(R", except that they are used on ".xx" lines,
53 '''   such as .IP and .SH, which do another additional levels of
54 '''   double-quote interpretation
55 .ds M" """
56 .ds S" """
57 .ds N" """""
58 .ds T" """""
59 .ds L' '
60 .ds R' '
61 .ds M' '
62 .ds S' '
63 .ds N' '
64 .ds T' '
65 'br\}
66 .el\{\
67 .ds -- \(em\|
68 .tr \*(Tr
69 .ds L" ``
70 .ds R" ''
71 .ds M" ``
72 .ds S" ''
73 .ds N" ``
74 .ds T" ''
75 .ds L' `
76 .ds R' '
77 .ds M' `
78 .ds S' '
79 .ds N' `
80 .ds T' '
81 .ds PI \(*p
82 'br\}
83 .\"     If the F register is turned on, we'll generate
84 .\"     index entries out stderr for the following things:
85 .\"             TH      Title
86 .\"             SH      Header
87 .\"             Sh      Subsection
88 .\"             Ip      Item
89 .\"             X<>     Xref  (embedded
90 .\"     Of course, you have to process the output yourself
91 .\"     in some meaninful fashion.
92 .if \nF \{
93 .de IX
94 .tm Index:\\$1\t\\n%\t"\\$2"
95 ..
96 .nr % 0
97 .rr F
98 .\}
99 .TH TEX2LYX 1 "Version 2.9.2.2 2.9.2.2" "16/Jul/2005" ""
100 .UC
101 .if n .hy 0
102 .if n .na
103 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
104 .de CQ          \" put $1 in typewriter font
105 .ft CW
106 'if n "\c
107 'if t \\&\\$1\c
108 'if n \\&\\$1\c
109 'if n \&"
110 \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
111 '.ft R
112 ..
113 .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
114 .       \" AM - accent mark definitions
115 .bd B 3
116 .       \" fudge factors for nroff and troff
117 .if n \{\
118 .       ds #H 0
119 .       ds #V .8m
120 .       ds #F .3m
121 .       ds #[ \f1
122 .       ds #] \fP
123 .\}
124 .if t \{\
125 .       ds #H ((1u-(\\\\n(.fu%2u))*.13m)
126 .       ds #V .6m
127 .       ds #F 0
128 .       ds #[ \&
129 .       ds #] \&
130 .\}
131 .       \" simple accents for nroff and troff
132 .if n \{\
133 .       ds ' \&
134 .       ds ` \&
135 .       ds ^ \&
136 .       ds , \&
137 .       ds ~ ~
138 .       ds ? ?
139 .       ds ! !
140 .       ds /
141 .       ds q
142 .\}
143 .if t \{\
144 .       ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
145 .       ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
146 .       ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
147 .       ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
148 .       ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
149 .       ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
150 .       ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
151 .       ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
152 .       ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
153 .\}
154 .       \" troff and (daisy-wheel) nroff accents
155 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
156 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
157 .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
158 .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
159 .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
160 .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
161 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
162 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
163 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
164 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
165 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
166 .ds ae a\h'-(\w'a'u*4/10)'e
167 .ds Ae A\h'-(\w'A'u*4/10)'E
168 .ds oe o\h'-(\w'o'u*4/10)'e
169 .ds Oe O\h'-(\w'O'u*4/10)'E
170 .       \" corrections for vroff
171 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
172 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
173 .       \" for low resolution devices (crt and lpr)
174 .if \n(.H>23 .if \n(.V>19 \
175 \{\
176 .       ds : e
177 .       ds 8 ss
178 .       ds v \h'-1'\o'\(aa\(ga'
179 .       ds _ \h'-1'^
180 .       ds . \h'-1'.
181 .       ds 3 3
182 .       ds o a
183 .       ds d- d\h'-1'\(ga
184 .       ds D- D\h'-1'\(hy
185 .       ds th \o'bp'
186 .       ds Th \o'LP'
187 .       ds ae ae
188 .       ds Ae AE
189 .       ds oe oe
190 .       ds Oe OE
191 .\}
192 .rm #[ #] #H #V #F C
193 .SH "NAME"
194 \fBtex2lyx\fR \- translate well-behaved LaTeX into LyX
195 .SH "SYNOPSIS"
196 The simplest way to use \fBtex2lyx\fR is via the File->Import command
197 in LyX. That runs \fBtex2lyx\fR on the given file and loads the
198 resulting file into LyX. You should try that first, and call it from
199 the command line only if you need to use more complicated options.
200 .PP
201 \fBtex2lyx\fR [ \fB\-c\fR \fItextclass\fR ] [ \fB\-df\fR ] [ \fB\-o\fR \fIoutputdir\fR ] [\fB\-n\fR]
202 [\ \fB\-r\fR\ \fIrenv1\fR[,\fIrenv2\fR...]] [\ \fB\-s\fR\ \fIsfile1\fR[,\fIsfile2\fR...]]
203 \fIinputfile\fR
204 .PP
205 \fBtex2lyx\fR \fB\-p\fR \fB\-c\fR \fItextclass\fR [ \fB\-df\fR ] [ \fB\-o\fR \fIoutputdir\fR ]
206 [\ \fB\-r\fR\ \fIrenv1\fR[,\fIrenv2\fR...]] [\ \fB\-s\fR\ \fIsfile1\fR[,\fIsfile2\fR...]]
207 \fIinputfiles\fR
208 .PP
209 \fBtex2lyx\fR \fB\-h\fR
210 .SH "OPTIONS"
211 .Ip "\fB\-c\fR" 4
212 Class. By default, when \fBtex2lyx\fR sees a \f(CW\edocumentclass{foo}\fR command, it
213 creates a file of textclass \*(L"foo\*(R" and reads the LyX layout file for that class
214 (something like /usr/local/share/lyx/layouts/foo.layout \s-1OR\s0
215 \fB\s-1HOME\s0\fR/.lyx/layouts/foo.layout).  Use \fB\-c\fR to declare a different textclass
216 (and read a different layout file).
217 .Ip "\fB\-d\fR" 4
218 Debug. By default, \fBtex2lyx\fR gives sparse output and deletes the temporary files
219 which were created during translation. Using the \fB\-d\fR flag will create much
220 more output (both to stdout and stderr) and leave the temporary files around.
221 .Ip "\fB\-f\fR" 4
222 Force. \fBtex2lyx\fR will not run if the .lyx file it would generate already exists
223 Use the \fB\-f\fR option (carefully) to clobber any existing files.
224 .Ip "\fB\-h\fR" 4
225 Help. Print out usage information and quit.
226 .Ip "\fB\-n\fR" 4
227 Noweb. Translate a noweb (aka literate programming) file. This should be
228 (almost?) equivalent to running \*(L"noweb2lyx foo.tex foo.lyx\*(R". This option
229 requires the \fB\-c\fR option.
230 .Ip "\fB\-o\fR" 4
231 Output directory. With this option, all temporary files and LyX output files
232 (for the given input file, for any included files, or for any file fragments
233 given with the \fB\-p\fR option) will be put into \fIoutputdir\fR. Otherwise, for
234 each file \fIdir/foo.tex\fR, the temporary files and the LyX output file will be
235 created in \fIdir\fR. This can be useful if a file includes files from other
236 directories which you want to consolidate in one directory, or if you don't
237 have write permission on the directory the LaTeX files are in.
238 .Ip "\fB\-p\fR" 4
239 Partial file. The input files are LaTeX fragments, with no preamble matter or
240 \f(CW\ebegin{document}\fR commands. This option requires the \fB\-c\fR option, since there
241 are no \f(CW\edocumentclass\fR commands in the files \fBtex2lyx\fR is translating. When
242 using this option, you can translate more than one file, as long as all files
243 are the same class. The LyX file created by \fBtex2lyx\fR can be included in an
244 existing LyX file using the \*(L"Include LyX File\*(R" command from LyX's Insert menu.
245 .Ip "\fB\-r\fR" 4
246 Regular environments (see the section on \fISyntax Files\fR).  If you give more than one
247 environment, separate them with commas (not spaces). You'll probably need to
248 quote the environment list, especially if it has asterisk environments (foo*)
249 in it. If you use this command often, considering creating a personal syntax
250 file.
251 .Ip "\fB\-s\fR" 4
252 Syntax files. Input (one or more quoted, comma-separated) syntax files to read
253 in addition to the default. (see the section on \fISyntax Files\fR for details).
254 .SH "DESCRIPTION"
255 .Sh "Introduction"
256 \fBtex2lyx\fR will create a LyX file \fIdir/foo.lyx\fR from the LaTeX file
257 \fIdir/foo.tex\fR (unless the \fB\-o\fR option is used).
258 .PP
259 Suffixes .tex, .ltx and .latex are supported. If \fIinputfile\fR
260 does not exist and does not have one of these suffixes, \fBtex2lyx\fR will try to
261 translate \fIinputfile.tex\fR. (This is similar to the behavior of LaTeX.)
262 .PP
263 The purpose of \fBtex2lyx\fR is to translate \fIwell-behaved\fR LaTeX2e into LyX. If
264 your LaTeX file doesn't compile---or if you do weird things, like redefining
265 standard LaTex commands---it may choke. LaTeX209 will often be translated
266 correctly, but it's not guaranteed.
267 .PP
268 \fBtex2lyx\fR has some bugs and lacks a few features. However, its main goals are:
269 .Ip "\(bu" 4
270 Get through a well-behaved LaTeX2e file without crashing
271 .Ip "\(bu" 4
272 Translate a lot of that file.
273 .Ip "\(bu" 4
274 Localize the parts that can't be translated and copy them in TeX mode
275 .PP
276 It achieves these main goals pretty well on most files.
277 .PP
278 There are many improvements that can and will be made to \fBtex2lyx\fR in the
279 future. However, we wanted to get \fBtex2lyx\fR out there early on, to make
280 it easier for new LyX users to read in their existing LaTeX files.
281 .Sh "Usage"
282 Here's a more lengthy description of what you should do to translate a LaTeX
283 document into LyX.
284 .Ip "\(bu" 4
285 Run \fBtex2lyx\fR.
286 .Sp
287 \fBtex2lyx\fR will inform you of its progress and give any warnings to stderr, so if
288 you don't want any output at all, try (in csh) \*(L'tex2lyx foo.tex >& /dev/null\*(R'.
289 You should \s-1NOT\s0 redirect standard output to \fIfoo.lyx\fR.
290 .Ip "\(bu" 4
291 Run LyX (version 0.12 or 1.0 or later) on the resulting .lyx file.
292 .Sp
293 In theory, most of the file will have been translated, and anything that's
294 untranslatable will be highlighted in red (TeX mode). In theory, LyX will be
295 able to read in the file, and to create printed documents from it, because all
296 that untranslated red stuff will be passed directly back to LaTeX, which LyX
297 uses as a backend. Unfortunately, reality doesn't always reflect theory. If
298 \fBtex2lyx\fR crashes, or LyX cannot read the generated LyX file, see the \f(CWBUGS\fR entry elsewhere in this document or the \fI\s-1BUGS\s0\fR file.
299 .Ip "\(bu" 4
300 Change things that are highlighted in red (TeX mode) by hand in LyX.
301 .Sp
302 As mentioned above, you should be able to print out the LyX file even without
303 doing this. However, changing a command in TeX mode to the corresponding LyX
304 object will allow you to take advantage of LyX's \s-1WYSIWYM\s0 editing.
305 .Sp
306 \fBtex2lyx\fR is not guaranteed to create a LyX file which generates exactly the same
307 output as the LaTeX file, but it should come close. \fBrelyX\fR will generally err
308 on the side of translating less to ensure that dvi or ps files are accurate,
309 even though this leads to more \*(L"evil red text\*(R" and less \s-1WYSIWYM\s0.
310 .Ip "\(bu" 4
311 \s-1PROOFREAD\s0 \s-1THE\s0 \s-1DOCUMENT\s0!!
312 .Sp
313 I'm sure you were planning on doing this anyway, but it's particularly
314 important after translating a LaTeX document. \fBtex2lyx\fR is, at least now, better
315 at \*(L"macro-translating\*(R" (translating the whole document) than
316 \*(L"micro-translating\*(R" (translating every little detail). For example, you may see
317 extra spaces or deleted spaces. Space handling has improved, but it's
318 not perfect.
319 .Sh "What tex2lyx Can Handle"
320 \fBtex2lyx\fR understands many LaTeX commands. It will translate:
321 .Ip "\(bu" 4
322 regular text, including mini-commands like ~, \*(L'\*(R', \f(CW\e@\fR, \f(CW\eTeX\fR, as well as
323 accented characters like \f(CW\e'{a}\fR, and the special cases ?` and !`
324 .Ip "\(bu" 4
325 title commands like \f(CW\eauthor\fR, \f(CW\edate\fR, \f(CW\etitle\fR, \f(CW\ethanks\fR and the
326 abstract environment
327 .Ip "\(bu" 4
328 heading commands like \f(CW\esection\fR including starred commands (\f(CW\esection*\fR)
329 .Ip "\(bu" 4
330 Environments: quote, quotation, and verse; center, flushright, and flushleft
331 .Ip "\(bu" 4
332 itemize, enumerate, and description environments, and their \f(CW\eitem\fR commands.
333 Also, well-behaved nested lists
334 .Ip "\(bu" 4
335 cross-referencing commands: \f(CW\eref\fR, \f(CW\epageref\fR, \f(CW\elabel\fR, and \f(CW\ecite\fR
336 .Ip "\(bu" 4
337 \f(CW\efootnote\fR and \f(CW\emargin\fR
338 .Ip "\(bu" 4
339 font-changing commands including \f(CW\eem\fR, \f(CW\eemph\fR, \f(CW\etextit\fR, and
340 corresponding commands to change family, size, series, and shape
341 .Ip "\(bu " 4
342 \f(CW\einput{foo}\fR (or \f(CW\einput{foo.blah}\fR) and \f(CW\einclude{foo}\fR. Plain TeX
343 \f(CW\einput\fR command \*(L"\f(CW\einput foo.tex\fR\*(R" is also supported.
344 .Ip "\(bu" 4
345 tabular environment, and commands that go inside it like \f(CW\ehline\fR, \f(CW\ecline\fR,
346 and \f(CW\emulticolumn\fR (but see below)
347 .Ip "\(bu" 4
348 float environments table and table*, as well as \f(CW\ecaption\fR commands within
349 them
350 .Ip "\(bu" 4
351 float environments figure and figure*, as well as graphics inclusion commands
352 \eepsf, \eepsffile, \eepsfbox, \eepsfxsize, \eepsfig, \epsfig, and \eincludegraphics.
353 Both the graphics and graphicx forms of \eincludegraphics are supported.
354 Note, however, that many figures will not be translatable into LyX. See
355 the section on \*(L"What LyX Can't Handle\*(R" below.
356 .Ip "\(bu" 4
357 thebibliography environment and \f(CW\ebibitem\fR command, as well as BibTeX's
358 \f(CW\ebibliography\fR and \f(CW\ebibliographystyle\fR commands
359 .Ip "\(bu" 4
360 miscellaneous commands: \f(CW\ehfill\fR, \f(CW\e\fR\f(CW\e\fR, \f(CW\enoindent\fR, \f(CW\eldots\fR...
361 .Ip "\(bu" 4
362 documentclass-specific environments (and some commands) which can be
363 translated to LyX layouts
364 .Ip "\(bu" 4
365 arguments to certain untranslatable commands (e.g. \f(CW\embox\fR)
366 .PP
367 Some of this support may not be 100% yet. See below for details
368 .PP
369 \fBtex2lyx\fR copies math (almost) verbatim from your LaTeX file. Luckily, LyX reads
370 in LaTeX math, so (almost) any math which is supported by LyX should work just
371 fine. A few math commands which are not supported by LyX will be replaced with
372 their equivalents, e.g., \f(CW\eto\fR is converted to \f(CW\erightarrow\fR. See
373 the section on \fISyntax Files\fR for more details.
374 .PP
375 \fBtex2lyx\fR will also copy any preamble commands (i.e., anything before
376 \f(CW\ebegin{document}\fR) verbatim, so fancy stuff you've got in your preamble
377 should be conserved in dvi and printed documents, although it will not of
378 course show up in the LyX window. Check Layout->LaTeX Preamble to make sure.
379 .Sh "What tex2lyx Can't Handle --- But it's \s-1OK\s0"
380 .Ip "\(bu" 4
381 tabular* tables
382 .Ip "\(bu" 4
383 minipages
384 .Ip "\(bu" 4
385 spacing commands (\f(CW\evspace\fR, \f(CW\epagebreak\fR, \f(CW\epar\fR, ...)
386 .Ip "\(bu" 4
387 \f(CW\ecentering\fR, \f(CW\eraggedleft\fR, \f(CW\eraggedright\fR
388 .Ip "\(bu" 4
389 \f(CW\everb\fR and verbatim environment. \fBtex2lyx\fR is careful to copy \fIexactly\fR in
390 this case, including comments and whitespace.
391 .Ip "\(bu" 4
392 some unknown (e.g., user-defined) environments and commands
393 .PP
394 \fBtex2lyx\fR copies unknown commands, along with their arguments, verbatim into the
395 LyX file. Also, if it sees a \f(CW\ebegin{foo}\fR where it doesn't recognize the
396 \*(L"foo\*(R" environment, it will copy verbatim until it sees \f(CW\eend{foo}\fR (unless
397 you use the \fB\-r\fR option). Hopefully, then, most of these unknown commands
398 won't cause \fBtex2lyx\fR to break; they'll merely require you to do some editing
399 once you've loaded the file up in LyX.  That should be less painful than
400 editing either the .tex or the .lyx file using a text editor.
401 .Sh "What tex2lyx Handles Badly --- aka \s-1BUGS\s0"
402 Since \fBtex2lyx\fR is relatively new, it's got a number of problems.  As it
403 matures, these bugs will be squished.
404 .PP
405 If \fBtex2lyx\fR is choking on something, or LyX can't read it after \fBtex2lyx\fR
406 translates it, the best thing to do is to put \f(CW\ebegin{tex2lyxskip}\fR before the
407 offending text, and \f(CW\eend{tex2lyxskip}\fR after it. I call this a \*(L"skip\*(R" block.
408 \fBtex2lyx\fR will copy this block exactly, in TeX mode. Then edit the resulting
409 LyX file, and translate the unknown stuff by hand. The tex2lyxskip environment
410 is magical; the \f(CW\ebegin\fR and \f(CW\eend\fR commands will not be put into the LyX
411 file.
412 .Ip "\(bu" 4
413 \*(L"Exact\*(R" copying of unknown environments and commands isn't quite exact.
414 Specifically, newlines and comments may be lost. This will yield ugly LyX, but
415 in almost all cases the output will be the same. However, certain parts of the
416 file will be copied perfectly, including whitespace and comments. This
417 includes: the LaTeX preamble, verbatim environments and \f(CW\everb\fR commands, and
418 skip blocks.
419 .Ip "\(bu" 4
420 \fBtex2lyx\fR translates only a few options to the \f(CW\edocumentclass\fR command.
421 (Specifically 1[012]pt, [letter|legal|executive|a4|a5|b5]paper,
422 [one|two]side, landscape, and [one|two]column.) Other options are placed in
423 the \*(L"options\*(R" field in the Layout->Document popup.
424 .Sp
425 More importantly, \fBtex2lyx\fR doesn't translate \f(CW\eusepackage\fR commands, margin
426 commands, \f(CW\enewcommands\fR, or, in fact, anything else from the preamble. It
427 simply copies them into the LaTeX preamble. If you have margin commands in
428 your preamble, then the LyX file will generate the right margins. However,
429 these margins will override any margins you set in the LyX Layout->Paper
430 popup. So you should remove the options from the preamble
431 (Layout->Latex Preamble) to be safe. The same goes for setting your language
432 with babel, \f(CW\einputencoding\fR, \f(CW\epagestyle\fR, etc.
433 .Ip "\(bu" 4
434 The foil class has a couple bugs. \fBtex2lyx\fR may do weird things with optional
435 arguments to \f(CW\efoilhead\fR commands. Also, it may handle \f(CW\ebegin{dinglist}\fR
436 incorrectly (although the stuff in the environment should translate normally).
437 .PP
438 Less significant bugs can be found in the \fI\s-1BUGS\s0\fR file.
439 .PP
440 \fBtex2lyx\fR is hopefully rather robust. As mentioned above, it may not translate
441 your file perfectly, but it shouldn't crash. If it does crash---and the
442 problem is not one of those mentioned above or in the \fI\s-1BUGS\s0\fR file---see
443 the section on \fIBug Reports\fR.
444 .Sh "What LyX Can't Handle"
445 LyX itself is missing a couple features, such that even if \fBtex2lyx\fR translates
446 things perfectly, LyX may still have trouble reading it. If you really need
447 these features, you can export your final document as LaTeX, and put them
448 back in. See \fI\s-1BUGS\s0\fR for more details on these bugs.
449 .Ip "\(bu" 4
450 For a number of commands, LyX does not support the optional argument. Examples
451 include \f(CW\echapter\fR (and other sectioning commands), and \f(CW\e\e\fR.
452 \fBtex2lyx\fR will automatically discard the optional arguments with a warning to
453 stdout.  LyX also ignores the width argument for the thebibliography
454 environment.
455 .Ip "\(bu" 4
456 Centering (or right or left justifying) works on full paragraphs.
457 .Ip "\(bu" 4
458 LyX support for tables isn't perfect. For complicated tables, use a \*(L"skip\*(R"
459 block, so that they will be copied in TeX mode.
460 .Ip "\(bu" 4
461 The LyX math editor can't handle the \s-1AMS\s0\-LaTeX math environments align, split,
462 etc. So those environments will be copied in TeX mode. You can change
463 equation* environments to the exactly equivalent displaymath, and then they
464 will be translated correctly.
465 .Ip "\(bu" 4
466 Lyx does not support clipping or bounding boxes for included graphics files.
467 Therefore, many graphics inclusion commands will be untranslatable, and
468 copied in TeX mode. In certain cases, you might be able to translate the
469 command by hand within LyX---for example, if you included a bounding box but
470 the bounding box is already in the .eps file.
471 .Sp
472 LyX only allows figures to have sizes in in,cm, or percentages of \etextwidth
473 or \etextheight (or \ecolumnwidth). \fBtex2lyx\fR will translate from other units, like
474 pt or mm, but it cannot translate other lengths (e.g. if you wanted to scale a
475 figure to size \etopmargin for some reason). \fBtex2lyx\fR will copy figures with
476 untranslatable sizes in TeX mode. Again, you might be able to fix that within
477 LyX.
478 .Sh "The Future of tex2lyx"
479 In the future, more commands and environments will be supported by \fBtex2lyx\fR.
480 Bugs will be eradicated.
481 .PP
482 See the \s-1TODO\s0 file for details.
483 .SH "EXAMPLES"
484 tex2lyx \fB\-df\fR \fB\-o\fR \*(L"my/dir\*(R" \fB\-r\fR \*(L"myenv\*(R" foo.tex > foo.debug
485 .PP
486 The above will create a file my/dir/foo.lyx from foo.tex, overwriting if
487 necessary.  When it finds a \f(CW\ebegin{myenv} ... \eend{myenv}\fR block, it will
488 translate the stuff within the block, but copy the \f(CW\ebegin\fR and \f(CW\eend\fR
489 commands in TeX mode.  Finally, I'm going to keep the temporary files around
490 (they will also be in my/dir/) and output lots of debugging information into
491 the file foo.debug.
492 .PP
493 tex2lyx \fB\-n\fR \fB\-c\fR \*(L"literate-article\*(R" foo.tex
494 .PP
495 The above will change a noweb document into a LyX literate-article
496 document. A user would do this if the noweb document had documentclass
497 article.
498 .SH "NOTES"
499 .Sh "Bug Reports"
500 If \fBtex2lyx\fR is crashing or otherwise acting strangely---in ways
501 other than those described in the section on \fI\s-1BUGS\s0\fR or the \fI\s-1BUGS\s0\fR file---then please run
502 \fBtex2lyx \-d\fR.  That will allow you to figure out where in the tex2lyxing process
503 it crashed. That, in turn, will allow you to write a better bug report, which
504 will allow the developers to fix it more quickly and easily.
505 .PP
506 Bug reports should be sent to the LyX developers\*(R' mailing list. Its address
507 is currently lyx-devel@lists.lyx.org, but you can check the LyX home page,
508 http://www.lyx.org if that bounces. If you are running \fBtex2lyx\fR on a huge file,
509 please do not send all of the output in your bug report. Just include the last
510 ten or twenty lines of output, along with the piece of the LaTeX file it
511 crashed on.  Or, even better, attach a small but complete file which causes
512 the same problem as your original file.
513 .Sh "Implementation Details:"
514 \fBtex2lyx\fR makes several \*(L"passes\*(R" in order to translate a TeX file. On each pass,
515 it creates one or two files.
516 .Ip "Pass 0" 4
517 Before doing anything, read the syntax file (or files).
518 .Ip "Pass 1a" 4
519 Split preamble (anything before a \f(CW\ebegin{document}\fR command) off the rest
520 of the file. It saves the two pieces in separate files. This is necessary
521 because there may be very strange stuff in a preamble. It also ignores
522 anything after the \f(CW\eend{document}\fR, on the assumption that it isn't LaTeX.
523 .Ip "Pass 1b" 4
524 Translate the preamble. Currently, that just means translating the
525 \f(CW\edocumentclass\fR command and copying the rest exactly into the LyX preamble.
526 .Sp
527 Once you know what class the document is, read the LyX layout file for that
528 class.
529 .Ip "Pass 2" 4
530 \*(L"Clean\*(R" the TeX file, generating slightly stricter LaTeX. This includes:
531 .Ip "\(bu" 12
532 Change, e.g., x^2 to the equivalent but clearer x^{2}
533 .Ip "\(bu" 12
534 Removing optional arguments that LyX can't handle (e.g., from \f(CW\echapter\fR)
535 .Ip "\(bu" 12
536 Changing \f(CW{\eem foo}\fR to \f(CW\eemph{foo}\fR, etc. This is necessary because LyX
537 always writes out the non-local forms anyway. This should very rarely make a
538 difference.
539 .Ip "Pass 3" 4
540 Translate LaTeX text, commands, and environments to LyX.
541 .Ip "Pass 4" 4
542 Put the two pieces back together, and do some final tweaking, to generate the
543 LyX file
544 .PP
545 If there are any \f(CW\einput\fR or \f(CW\einclude\fR commands, \fBtex2lyx\fR will loop back to
546 the beginning and translate those. It assumes that the included files are the
547 same class as the main file, and that they have no preamble matter. (If you
548 have an \f(CW\einput\fR command in the preamble of a file, the command will be
549 copied exactly into the LaTeX preamble portion of the LyX file, so the
550 included file won't be translated.) So when translating included files, it
551 skips passes 0 and 1.
552 .PP
553 If \fBtex2lyx\fR doesn't find a file you wanted to include, it will give a warning,
554 but will continue to translate any files it does find.
555 .Sh "Layout Files"
556 \fBtex2lyx\fR reads a LyX layout file to know how to handle LaTeX environments and
557 commands which get translated to LyX layouts. This file will include all
558 \*(L"normal\*(R" non-math environments (i.e., including quote and itemize, but not
559 tabular, minipage, and some other fancy environments), and commands like
560 \f(CW\esection\fR and \f(CW\etitle\fR. If you want to tex2lyx a class that doesn't have an
561 existing layout file, then you'll have to create a layout file. But you have
562 to do this anyway, in order to LyX the file, since LyX depends on layout files
563 to know how to display and process its files. Check the LyX documentation for
564 help with this task (which can be hard or easy, depending on the class you
565 want to create a layout file for.) If your class is quite similar to a class
566 that has a layout file, then consider using the \fB\-c\fR option.
567 .Sh "Syntax Files"
568 \fBtex2lyx\fR always reads at least one syntax file, called the default syntax file.
569 \fBtex2lyx\fR will read your personal syntax file if it exists; otherwise it will
570 read the system-wide file. \fBtex2lyx\fR will read additional syntax files if you
571 specify them with the \fB\-s\fR option. (These extra files should have the same
572 format as the default file, but will tend to be shorter, since they only have
573 to specify extra commands not found in the default file.) A syntax file tells
574 \fBtex2lyx\fR a few things.
575 .PP
576 First, it describes the syntax of each command, that is, how many required
577 arguments and how many optional arguments the command takes. Knowing this
578 makes it easier for \fBtex2lyx\fR to copy (in TeX mode) commands that it doesn't
579 know how to translate. The syntax file simply has a command, followed by
580 braces or brackets describing its arguments in the correct order. For example,
581 a syntax file entry \f(CW\ebibitem[]{}\fR means that the \f(CW\ebibitem\fR command takes
582 an optional argument followed by a required one, while the entry \f(CW\ebf\fR
583 means that the \f(CW\ebf\fR command takes no arguments at all.  When \fBtex2lyx\fR
584 encounters a token that it doesn't know how to translate into LyX, it will
585 copy the token---along with the correct number of arguments---exactly.  If the
586 token is not in the syntax file, then \fBtex2lyx\fR just copies as many arguments
587 as it finds.  This means that it may copy too much. But since the user can
588 specify additional syntax files, that shouldn't happen often.
589 .PP
590 Some commands that cannot be translated to LyX, like \f(CW\embox\fR, have as one of
591 their arguments regular LaTeX text. If the string \*(L"translate\*(R" is put into an
592 argument of an (untranslatable) command in the syntax file, then \fBtex2lyx\fR will
593 translate that argument instead of copying it verbatim. So, for example, the
594 default syntax file has \f(CW\eraisebox{}[][]{translate}\fR. This means that the
595 \f(CW\eraisebox\fR command and the first argument (and optional arguments if they
596 exist) are copied in TeX mode, but the last argument (which may contain math,
597 complicated LaTeX, other untranslatable commands, etc.) will be translated
598 into LyX. You can't use \*(L"translate\*(R" on optional arguments.
599 .PP
600 User-defined syntax files are allowed to define new commands and
601 their syntax, or override the number of arguments for a command given in the
602 default syntax file. (E.g., if you're using a style that gives an extra
603 argument to some command...) However, this will only be useful for commands
604 copied in TeX mode. Commands which are actually translated by \fBtex2lyx\fR (like
605 \f(CW\eitem\fR) have their argument syntax hard-coded. The hard-coded commands are
606 identified in the default syntax file.
607 .PP
608 Second, the syntax file describes any \*(L"regular environments\*(R".  Usually, an
609 entire unknown environment will be copied in TeX mode. If you define a regular
610 environment \*(L"foo\*(R", though, then only the \f(CW\ebegin{foo}\fR and \f(CW\eend{foo}\fR
611 commands will be copied in TeX mode; the text within the environment will be
612 treated (i.e., translated) by \fBtex2lyx\fR as regular LaTeX, rather than being
613 copied into TeX mode. Don't try to declare \*(L"tabbing\*(R" and \*(L"picture\*(R" as regular
614 environments, as the text within those environments will confuse \fBtex2lyx\fR; use
615 this capability for new environments you create that have plain text or math
616 or simple commands in them. You also can't declare unknown math environments
617 (like equation*) as regular environments, either, since the LyX math editor
618 won't understand them. The names of regular environments appear,
619 whitespace-separated, between \f(CW\ebegin{tex2lyxre}\fR and \f(CW\eend{tex2lyxre}\fR
620 statements in the syntax file. (If you have a regular environment which you
621 won't use very often, you can use the \fB\-r\fR option rather than writing a
622 syntax file.)
623 .Sh "Miscellaneous"
624 You need Perl version 5.002 or later to run \fBtex2lyx\fR. <plug> If you don't have
625 Perl, you should get it anyway (at http://www.perl.com), because it's a really
626 useful tool for pretty much anything. </plug>
627 .SH "DIAGNOSTICS"
628 \fBtex2lyx\fR should always explain why it crashes, if it crashes. Some diagnostics
629 may be very technical, though, if they come from the guts of the code.
630 \fBtex2lyx\fR gives much more information while running if you use the \fB\-d\fR option,
631 but you shouldn't need that unless something goes wrong.
632 .PP
633 When it's finished, \fBtex2lyx\fR will tell you if it finished successfully or
634 died due to some error.
635 .SH "WARNINGS"
636 Always keep a copy of your original LaTeX files either under a different
637 name or in a different directory. There are a couple ways in which using LyX
638 could lead to overwriting the original LaTeX file.
639 .PP
640 If you import foo.tex to create foo.lyx, then edit foo.lyx and want to
641 re-export it, note that it will overwrite the original foo.tex. (LyX will ask
642 you if you want to overwrite it.)
643 .PP
644 If you have the \euse_tempdir variable set to false in your lyxrc, then LyX
645 will create its temporary files in your current directory, which means your
646 LaTeX original may be overwritten (without a warning from LyX) when you \*(L"view
647 dvi\*(R" or print the LyX document.
648 .SH "FILES"
649 .Ip "\fI\s-1MY_LYXDIR\s0\fR/layouts/*.layout" 4
650 User's personal layout files for document classes
651 .Ip "\fI\s-1MY_LYXDIR\s0\fR/syntax.default" 4
652 User's personal syntax file
653 .Ip "\fI\s-1LIBDIR\s0\fR/layouts/*.layout" 4
654 System-wide layout files for document classes
655 .Ip "\fI\s-1LIBDIR\s0\fR/lib/syntax.default" 4
656 System-wide LaTeX syntax file
657 .PP
658 \fI\s-1LIBDIR\s0\fR is the system-wide LyX directory, usually something like
659 /usr/local/share/lyx/. \fI\s-1MY_LYXDIR\s0\fR is your personal LyX directory, something
660 like .lyx/ in your home directory.
661 .SH "SEE ALSO"
662 \fIlyx\fR\|(1), \fIlatex\fR\|(1)
663 .SH "AUTHORS"
664 Copyright (c) 1998-9 Amir Karger (karger@post.harvard.edu)
665 .PP
666 Code contributors:
667 .Ip "\(bu" 4
668 John Weiss wrote the original CleanTeX pass.
669 .Ip "\(bu" 4
670 Etienne Grossmann
671 .Ip "\(bu" 4
672 Jose\*' Abi\*'lio Oliveira Matos
673 .Ip "\(bu" 4
674 David Suarez de Lis
675 .Ip "\(bu" 4
676 Kayvan Aghaiepour Sylvan added noweb stuff and wrote noweb2lyx
677 .PP
678 Other contributors:
679 .Ip "\(bu" 4
680 Jean-Marc Lasgouttes worked on the wrapper script and offered lots of bug
681 reports, advice, and feature suggestions.
682 .Ip "\(bu" 4
683 Asger K. Alstrup Nielsen and Marc Pavese provided advice.
684 .Ip "\(bu" 4
685 Various members of the LyX developers\*(R' and users\*(R' lists provided bug reports
686 and feature suggestions.
687
688 .rn }` ''
689 .IX Title "RELYX 1"
690 .IX Name "B<tex2lyx> - translate well-behaved LaTeX into LyX"
691
692 .IX Header "NAME"
693
694 .IX Header "SYNOPSIS"
695
696 .IX Header "OPTIONS"
697
698 .IX Item "\fB\-c\fR"
699
700 .IX Item "\fB\-d\fR"
701
702 .IX Item "\fB\-f\fR"
703
704 .IX Item "\fB\-h\fR"
705
706 .IX Item "\fB\-n\fR"
707
708 .IX Item "\fB\-o\fR"
709
710 .IX Item "\fB\-p\fR"
711
712 .IX Item "\fB\-r\fR"
713
714 .IX Item "\fB\-s\fR"
715
716 .IX Header "DESCRIPTION"
717
718 .IX Subsection "Introduction"
719
720 .IX Item "\(bu"
721
722 .IX Item "\(bu"
723
724 .IX Item "\(bu"
725
726 .IX Subsection "Usage"
727
728 .IX Item "\(bu"
729
730 .IX Item "\(bu"
731
732 .IX Item "\(bu"
733
734 .IX Item "\(bu"
735
736 .IX Subsection "What tex2lyx Can Handle"
737
738 .IX Item "\(bu"
739
740 .IX Item "\(bu"
741
742 .IX Item "\(bu"
743
744 .IX Item "\(bu"
745
746 .IX Item "\(bu"
747
748 .IX Item "\(bu"
749
750 .IX Item "\(bu"
751
752 .IX Item "\(bu"
753
754 .IX Item "\(bu "
755
756 .IX Item "\(bu"
757
758 .IX Item "\(bu"
759
760 .IX Item "\(bu"
761
762 .IX Item "\(bu"
763
764 .IX Item "\(bu"
765
766 .IX Item "\(bu"
767
768 .IX Item "\(bu"
769
770 .IX Subsection "What tex2lyx Can't Handle --- But it's \s-1OK\s0"
771
772 .IX Item "\(bu"
773
774 .IX Item "\(bu"
775
776 .IX Item "\(bu"
777
778 .IX Item "\(bu"
779
780 .IX Item "\(bu"
781
782 .IX Item "\(bu"
783
784 .IX Subsection "What tex2lyx Handles Badly --- aka \s-1BUGS\s0"
785
786 .IX Item "\(bu"
787
788 .IX Item "\(bu"
789
790 .IX Item "\(bu"
791
792 .IX Subsection "What LyX Can't Handle"
793
794 .IX Item "\(bu"
795
796 .IX Item "\(bu"
797
798 .IX Item "\(bu"
799
800 .IX Item "\(bu"
801
802 .IX Item "\(bu"
803
804 .IX Subsection "The Future of tex2lyx"
805
806 .IX Header "EXAMPLES"
807
808 .IX Header "NOTES"
809
810 .IX Subsection "Bug Reports"
811
812 .IX Subsection "Implementation Details:"
813
814 .IX Item "Pass 0"
815
816 .IX Item "Pass 1a"
817
818 .IX Item "Pass 1b"
819
820 .IX Item "Pass 2"
821
822 .IX Item "\(bu"
823
824 .IX Item "\(bu"
825
826 .IX Item "\(bu"
827
828 .IX Item "Pass 3"
829
830 .IX Item "Pass 4"
831
832 .IX Subsection "Layout Files"
833
834 .IX Subsection "Syntax Files"
835
836 .IX Subsection "Miscellaneous"
837
838 .IX Header "DIAGNOSTICS"
839
840 .IX Header "WARNINGS"
841
842 .IX Header "FILES"
843
844 .IX Item "\fI\s-1MY_LYXDIR\s0\fR/layouts/*.layout"
845
846 .IX Item "\fI\s-1MY_LYXDIR\s0\fR/syntax.default"
847
848 .IX Item "\fI\s-1LIBDIR\s0\fR/layouts/*.layout"
849
850 .IX Item "\fI\s-1LIBDIR\s0\fR/lib/syntax.default"
851
852 .IX Header "SEE ALSO"
853
854 .IX Header "AUTHORS"
855
856 .IX Item "\(bu"
857
858 .IX Item "\(bu"
859
860 .IX Item "\(bu"
861
862 .IX Item "\(bu"
863
864 .IX Item "\(bu"
865
866 .IX Item "\(bu"
867
868 .IX Item "\(bu"
869
870 .IX Item "\(bu"
871