generates tables
Generating tables in LaTex can be cumbersome. The FluentLaTexTableBuilder lets you create a standard LaTex table easily.
Example:
String latexTable = new FluentLaTexTableBuilder()
.withCaption("this is a latex table")
.withLabel("tab:latex table")
.withColumns(Arrays.asList("scenario","time","distance")
.withRow(Array.asList("ref","1000","12")
.withRow(Arrays.asList("cordon", "2000", "123"))
.build();
or you can use Guava's Splitter to split entire rows directly
String columns = "scenario,time,distance";
String row1 = "ref,1000,12";
String latexTable = new FluentLaTexTableBuilder()
.withCaption("this is a latex table")
.withLabel("tab:latex table")
.withColumns(Splitter.on(',').trimResults().split(columns))
.withRow(Splitter.on(',').trimResults().split(row1))
.withRow(Arrays.asList("cordon", "2000", "123"))
.build();
Both of the examples build a String containing the LaTex table pretty much like this
\begin{table}
\begin{center}
\caption{this is the first table}
\begin{tabular}{l | r | r}
\hline
scenario & time & distance \\
\hline
ref & 1000 & 12 \\
cordon & 2000 & 123 \\
\hline
\end{tabular}
\end{center}
\label{tab:first table}
\end{table}
###Format The default column format is 'l | r | r'. You change it with
.withFormat("| c | c | c |");
##without code
git clone https://github.com/oblonski/jTableGenerator.git
cd jTableGenerator
mvn package
java -jar target/jTableGenerator-1.0-SNAPSHOT.jar -in infile -out outfile -del delimiterInfile
Example:
Assume an infile called scenario.txt which looks like this
scenario,time,distance
ref,1000,12
cordon,2000,123
java -jar target/jTableGenerator-1.0-SNAPSHOT.jar -in scenario.txt -out latexTableScenario.txt -del ,
creates a file latexTableScenario.txt containing
\begin{table}
\begin{center}
\caption{this is the first table}
\begin{tabular}{l | r | r}
\hline
scenario & time & distance \\
\hline
ref & 1000 & 12 \\
cordon & 2000 & 123 \\
\hline
\end{tabular}
\end{center}
\label{tab:first table}
\end{table}