-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemopaper.tex
92 lines (75 loc) · 2.34 KB
/
demopaper.tex
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
\documentclass{scrartcl}
\synctex=1
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{csvsimple}
\usepackage{courier}
\usepackage{listings,color}
\definecolor{gray}{gray}{0.8}
\lstset{language=Perl}
\lstset{commentstyle=\textit}
\lstset{frame=shadowbox, rulesepcolor=\color{gray}}
\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\title{How to combine LibreOffice Calc with LaTex tables?}
\author{Maximilian Noppel}
\begin{document}
\maketitle
\bibliographystyle{plain}
Use the following perl script as \texttt{.latexmkrc} in the main folder of your paper.
This file sets certain parameters for \texttt{latexmk}.
Also it alter the way \texttt{latexmk} handles \texttt{csv} slightly.
\begin{lstlisting}[numbers=left]
@default_files = ('demopaper.tex');
$pdflatex = 'pdflatex -synctex=1';
$interaction = "nonstopmode";
add_cus_dep("ods","csv",0,"ods2csv");
sub ods2csv {
if($_[0] eq ""){
return;
}
my $sourceods = "$_[0].ods";
my $sourcecsv = "$_[0].csv";
print "Processing $sourceods...\n";
system("libreoffice --headless --convert-to csv \"".
$sourceods."\" --outdir tables");
system("python src/preprocess_csv.py \"".$sourcecsv.
"\" --inplace");
return;
}
# Make sure all the dependencies get build initially
# Starting from here our real customization starts.
# First we scrap for all tables/*.ods files and put them in a list.
my @files = <tables/*.ods>;
my @dep_files = ();
foreach (@files) {
@dep_files = (@dep_files, $_)
}
# Then we iterate over the list
# and check if every corresponding csv file
# exists. If not we create it with the above
# rules. Luckily latexmk takes care for
# rerunning the upper routine whenever
# the .ods file changes, once the file exists...
foreach (@dep_files) {
my ($filetype) = $_ =~ /^.*\.(.*)$/igs;
my ($filename) = $_ =~ /^(.*)\..+/igs;
if($filetype eq "ods"){
if(-e $filename.".csv"){
}else{
ods2csv($filename);
}
}
}
\end{lstlisting}
\section*{Results}
Here you can see a table we created with our setup.
\begin{table}[!h]
\caption{
Our demotable from LibreOffice Calc
}
\label{tab:demotable}
\centering
\include{tables/demotable.tex}
\end{table}
\bibliography{bib/references}
\end{document}