Over the past few days I've struggled to get LyX 1.5.2 on WinXP to
recognize and use latex2rtf for Rich Text Format exports. Jurgen suggested
this to someone and it was a tool I needed, so I gave it a shot. The
process was beset by many troubles, and now that I finally have it working,
I describe it here to help other users on WinXP that need a way of sharing
documents with the underclass that use M$ products (hat tip to Paul).
Jurgen helped me a LOT along the way.
Ideally, one would simply:
(1) install latex2rtf from sourceforge (win-gui download here -
http://sourceforge.net/project/showfiles.php?group_id=22654)
(2) add the latex2rtf folder (C:\l2r -- see below) to the Windows search
path (see section 2.4 here -
http://sourceforge.net/project/showfiles.php?group_id=22654)
(3) open LyX, reconfigure, close, and restart
and the converter for Latex (plain) -> Rich Text Format would be sorted out
by LyX and a Rich Text Format option would be made available under File ->
Export.
Unfortunately, it ain't that easy.
First off, the above strategy works fine if all you want to do is use the
latex2rtf GUI (l2rshell.exe; the icon on the desktop calls this) to convert
existing .tex files to .rtf files. In fact, you only need (1) and (2) above
for that, and then you just export plain latex from LyX and run the
conversion manually. Getting LyX to recognize the converter (latex2rt.exe)
is the hard part, but it's nice to have LyX do all the work behind the scenes.
The first issue is that you should simply avoid installing the program
anywhere but C:\l2r. All of the defaults for the program assume that it is
installed at this path. I installed to Program Files because I had not read
section 2.4 here -
http://sourceforge.net/project/showfiles.php?group_id=22654 - first. It
explains how to adjust the three configuration files (more on these in a
minute) to make latex2rtf work from any installation path, but it never
worked for me, and I tried a lot of different things. No matter what I
tried, running LyX from the command prompt showed that the error was that
latex2rtf could not find its config directory (the cfg directory under the
latex2rtf root directory). It always assumed that the root directory was
C:\l2r despite the fact that all entries in the configuration files were
adjusted to reflect "C:\Program Files\latex2rtf", where I installed it. So,
make your life easy and install to C:\l2r. I never checked this with the
latex2rtf folks, but the simple solution seems to be obvious.
Next, you do need to add the latex2rtf folder to the Windows search path:
a. Right-click My Computer and go to Properties.
b. Advanced Tab -> Environment Variables -> System Variables -> Path, add
"C:\l2r;" (no quotes) somewhere in the line.
The next step varies depending on how you have LaTeX set up on your
machine. I used the LyXWinInstaller and this presents a new wrinkle for
latex2rtf.
Those three configuration files (.bat files) are in the latex2rtf root and
are L2R.BAT, L2RSEM.BAT, and L2RPREP.BAT. You'll need to edit them (use a
good text editor; i.e., not Notepad).
L2R and L2RSEM are almost identical, but notice that one of them (don't
recall which, I changed it), on line 15, has the German windows settings
line unremarked. The other one has the English windows settings unremarked.
I changed them both to have the English settings unremarked (i.e.,
functional) and the German settings remarked (i.e., unfunctional). I didn't
actually test whether this mattered, but it seemed prudent. The paths
should all be fine if you installed to C:\l2r and you need do nothing more
with these files.
At this point, I tried reconfiguring LyX and it still failed to find the
converter.
L2RPREP comes in - this is a bit tougher. I ran this file from a command
prompt to see that it set the paths correctly. As best I could tell,
"which" always failed to find the Ghostscript, LaTeX, and ImageMagick
files. So, I edited it to look as below (changes starting on line 8).
Again, this applies for people that use LyXWinInstaller only.
rem set folder containing Ghostscript executables here:
%l2rpath%\which gswin32c >nul
if errorlevel 1 SET PATH="C:\Program Files\LyX
1.5.2\etc\Ghostscript\bin";"C:\Program Files\LyX
1.5.2\etc\Ghostscript\lib";%PATH%
rem set folder containing ImageMagick executables here:
%l2rpath%\which identify >nul
if errorlevel 1 SET PATH="C:\Program Files\LyX 1.5.2\etc\ImageMagick";%PATH%
rem set folder containing LaTeX and dvips executables here:
%l2rpath%\which latex >nul
if errorlevel 1 SET PATH="C:\Program Files\MiKTeX 2.6\miktex\bin";%PATH%
The final "set l2rpath=" line appears superfluous, but it doesn't stop
things from working.
I also added "C:\Program Files\LyX 1.5.2;" (no quotes) to the Windows
search path. In my inexperienced mind this was to help "which" find the
above files, but I also edited the L2RPREP before reconfiguring LyX, so
these events are confounded when it comes to success/failure. Basically,
I'm not sure that this addition to the search path was necessary.
At this point, reconfiguring LyX and restarting finds the converter, which
appears in Tools -> Preferences -> Converters as Latex (plain) -> Rich Text
Format with the converter as:
latex2rt -p -S -o $$o $$i
The option shows up in Export and works fine.
For anyone with more experience with this, I'd appreciate knowing what I
did was necessary/unnecessary and any thoughts on the matter. Perhaps we
can put a final version without errors and unnecessary steps on the wiki.
Thanks,
Dave