I am trying to write a document in latex using emacs as an editor and I like being able to use orgtbl-mode to insert and edit tables "ascii art style", but I am annoyed at having to manually change the format of the tabular from {lll} to {|l|l|l|} whenever making changes to the table and compiling.
Is there a way to make having horizontal lines the default?
Example table:
|-------+-------+-------|
| | test1 | test2 |
|-------+-------+-------|
| test3 | | |
|-------+-------+-------|
| test4 | | |
|-------+-------+-------|
I want this to output the following table.
\begin{tabular}{|l|l|l|}
\hline
& test1 & test2 \\
\hline
test3 & & \\
\hline
test4 & & \\
\hline
\end{tabular}
and not this table:
\begin{tabular}{lll}
\hline
& test1 & test2 \\
\hline
test3 & & \\
\hline
test4 & & \\
\hline
\end{tabular}
You can use column groups from the Org manual.
Adding a line and a column (indicating the column groups)
| / | < | < | <> |
|---+-------+-------+-------|
| | | test1 | test2 |
|---+-------+-------+-------|
| | test3 | | |
|---+-------+-------+-------|
| | test4 | | |
|---+-------+-------+-------|
will generate the desired result:
\begin{tabular}{|l|l|l|}
\hline
& test1 & test2\\
\hline
test3 & & \\
\hline
test4 & & \\
\hline
\end{tabular}
The first column is added to get the vertical line on the far left of the table, and the ‘>’ indicating the end of a column in the last column of the first line is necessary to get the vertical line on the far right of the table.