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 `input`ed. 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).

Advertisement

About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.
This entry was posted in Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s