Site Map




Purpose: Copy a (sub)table from OpenOffice Calc and paste it into a LaTeX document.

The script permits a rather rapid copy and paste from OpenOffice Calc to a LaTeX document by using the converter csv2LaTeX. Besides its convenience, it avoids the formatting loss in the figures, e.g., number of desired digits, that happens when OpenOffice Calc converts to a CSV file. It uses KDE dcop to exchange the clipboard content format.

# calc2latex: Clipboard format exchange
# Pere Constans, Mar 6 2004 (uses csv2latex, by Benoit Rouits)
dcop klipper klipper getClipboardContents  |  sed 's%\t%;%g' > /tmp/csv2latex.tmp
TABLE=`csv2latex --nohead --separator s /tmp/csv2latex.tmp | grep -v "\end{document}"`
rm /tmp/csv2latex.tmp
dcop klipper klipper setClipboardContents "$TABLE"
echo calc2latex: converted clipboard to a latex table, paste it now.

Use: Select a table, copy it (ctrl-c), run the script (ctrl-...), and paste it (ctrl-p) to the text editor. Most text editors permit defining some sort of shortcut to external processes. Kile, for instance, permits assigning and calling the script under User -> User Tools.

See also: calc2latex - An OpenOffice macro for converting tables