## Latex with libreoffice (figures and tables)

Previous post here.

The issue with tables is that, unlike the normal flow of the latex document, they are completely foreign to someone who is not a latex user. My proposal, though still a bit unfriendly on the eyes (because a text table is not as pretty as a pdf one) allows my collaborator to get and edit the text.

My approach assumes that you have your tables and figures in separate files and you import them to your main latex with the input command. The main idea is to transform the figure and table files into text and then automatically insert them in the main latex document where they are inputed. The result is the same latex document except for the figures and tables which are in text format.

I use catdvi to do the latex->text formatting. I also use sed, echo, cat and latex. The following is the Makefile which I am using to do stuff. You should change the first three variable to the names of your main document, figures and tables files. Then just run make -f NameOfFile. You might also need to add different targets depending on what you need to compile your latex figure and table documents.

maindoc = paper.tex
figdoc = paperfig.tex
tabdoc = papertab.tex
TXTs = $(figdoc).txt$(tabdoc).txt
$(maindoc).txt:$(TXTs)
cat $(maindoc) >$(maindoc).txt
for tfile in $(subst .txt,,$(TXTs)); do \
sed -i -e "/input{$$tfile}/{r$$tfile.txt" -e "d}" $(maindoc).txt; \ done rm -rf$(TXTs)
$(TXTs): echo '\\documentclass{article}' >$@.tex
cat $(maindoc) | grep usepackage >>$@.tex
echo '\\begin{document}' >> $@.tex cat$(subst .txt,,$@) >>$@.tex
echo '\\end{document}' >> $@.tex latex$@.tex
catdvi $@.dvi >$@

Notice that this code will not include the actual figures into the txt document. I guess I’ll be doing that by hand. But with 5 to 10 figures should not be too time consuming. Also, the script does not have tab spaces, so Make might complain (I blame wordpress).