From Lyx/Latex to Word
This is sort of a placeholder post. Busy meeting a deadline, but this should help future Steve and anyone else when you need to turn your Lyx document into a Word document while keeping the format mostly sane. Broken, but sane.
- Export as
Latex (plain). -
Run
latex <name of tex file, with or without extension>
-
Run
bibtex <filename>
-
Run
latex <filename>
-
Run
latex <filename>
-
Try to run
htlatex <filename> "html,0,charset=utf-8" "" -dhtml/html: format to output0: normally chapters go into their own page, putting 0 here forces everything into a single pagecharset=utf-8: let us be civilised-dhtml/: puts the output files in a html sub-directory. Note that you can't have a space between-dand thehtml/
-
If the above fails with something like 'illegal storage address', and you get a warning about
text4ht.envnot been found, then you need to find where it is in your TeX installation, and:export TEX4HTENVand try again- Copy
text4ht.envinto your working directory - This approach also lets you affect locally some export parameters. More on this later...
-
Open the html to verify correctness. You might object to the poor graphics quality. In this case copy
text4ht.envinto the working directory if you haven't done so, and then modify it so it uses a high density when converting images. -
See this tex.stackexchange.com answer for more details
- In my case, since dvipng was been used, I replaced all instances of
-D 96- with
-D 300
-
It also helps if you
-
strip away html comments
- These look like
<!-- xxx --> - centre aligned image divs
- remove
<hr/>instances
- These look like
-
These changes will make the import into Libre/OpenOffice go easier
-
Open the html file in Libre/OpenOffice
-
File > Export > ODT
-
Close html file
-
Open exported ODT
-
Edit > Links
-
Select all links
-
Break Links
-
Verify that the ODT file is now much larger!
-
File > Save As > Word 97 (doc)
Phew! To help future visitors, a simple python script to fix up the html as I have described is included at the end of this post. You will need lxml and cssselector installed. Cheers, Steve
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |