Archive for February, 2013

Strip The Junk Out of Word or Writer Files with Writer2LaTeX and Pandoc

While playing around with LaTeX stuff I noticed that the clean article and ultra-clean article Writer2LaTeX options were quite useful. It occurred to me that aside from converting anything Writer can open to LaTeX, this might also be used to strip the cruft from those very same files. Just convert them back to ODT afterward.

pandoc -o output.odt input.tex

Since Writer2LaTeX was a command-line utility before it became a LibreOffice extension, we can automate it a bit more like this after installing the writer2latex package:

w2l -latex -ultraclean input.odt

Unfortunately that won’t handle everything LibreOffice does. If you want to stick to the command line you can take care of that like this:

loffice --headless --convert-to odt input.docx

I stuck it all in a shell script:


SCRIPT_NAME=`basename "$0" .sh`

mkdir ${TMP_DIR}
cp $1 ${TMP_DIR}
cd ${TMP_DIR}

#convert to ODT if the file is DOC or something
if [ "$EXTENSION" != "odt" ]
	loffice --headless --convert-to odt $1

w2l -latex -ultraclean ${FILENAME}.odt
pandoc -o ${OUTPUT_FILENAME} ${FILENAME}.tex

rm *
cd ..
rmdir ${TMP_DIR}

And thus you end up with a much more manageable Writer file. Just be careful: e.g. tables aren’t supported by Pandoc quite properly.


Compose Key on Xfce

Since the compose key is one of my favorite things in Linux, I was rather disappointed not to immediately find an obvious means of configuring it in Xfce. Not to worry, the slightly unintuitive but still easy method of configuring the compose key consists of adding the Keyboard Layouts widget to one of your panels.

The Xfce Keyboard Layouts widget showing the option of which key to use as compose.

As much as I love the portability, readability, and power of plain-text configuration, for just setting a compose key I don’t think it can get much better than the Gnome keyboard configuration dialog. The easiest alternative method would seem to be xmodmap, which should work in any desktop environment, not just Xfce. But of course it didn’t, because Xfce somehow overwrites those settings. For the sake of completeness, here’s what I tried in ~/.Xmodmap:

clear Lock
keysym Caps_Lock = Multi_key

It might be better to use to setxkbmap.

So there you have it. I haven’t yet figured out the ideal way of setting up my keyboard, but as long as it works I’m not too bothered yet.

Comments (2)