|
| 1 | +--- |
| 2 | +title: "tables-vrules - Pandoc filter to add vertical rules to tables" |
| 3 | +author: "Christophe Agathon" |
| 4 | +--- |
| 5 | + |
| 6 | +Tables VRules |
| 7 | +======= |
| 8 | + |
| 9 | +Add vertical rules to tables. |
| 10 | + |
| 11 | +v1.0. Copyright: © 2021 Christophe Agathon |
| 12 | + |
| 13 | +License: MIT - see LICENSE file for details. |
| 14 | + |
| 15 | +Introduction |
| 16 | +------------ |
| 17 | + |
| 18 | +Since pandoc has a strong policy against vertical rules in tables, peole have been looking for solutions to get those, especially when rendering PDF files via Latex. |
| 19 | + |
| 20 | +For more information you can refer to : |
| 21 | + |
| 22 | +* This Pandoc issue [https://github.com/jgm/pandoc/issues/922](https://github.com/jgm/pandoc/issues/922) |
| 23 | +* This discussion on StackExchange [https://tex.stackexchange.com/questions/595615/how-can-i-reformat-a-table-using-markdown-pandoc-pdf/596005](https://tex.stackexchange.com/questions/595615/how-can-i-reformat-a-table-using-markdown-pandoc-pdf/596005) |
| 24 | + |
| 25 | +marjinshraagen proposed a solution based on a patch of `\LT@array` in Latex. It used to work pretty well. It doesn't anymore for Multiline Tables and Pipes Tables since Pandoc changed the Latex code it generates for those kind of tables. Don't know exactly when it changed but sometime between Pandoc version 2.9.2.1 and version 2.16. |
| 26 | + |
| 27 | +Since patching in Latex is tricky and I am not a Latex guru, I didn't manage to make it work again, so I made this filter which change the call to `longtable` to add vertical rules in a more "natural" whay. |
| 28 | + |
| 29 | + |
| 30 | +Usage |
| 31 | +----- |
| 32 | + |
| 33 | +### Formating the document |
| 34 | + |
| 35 | +Simply use on of the table synthax allowed by Pandoc (details in |
| 36 | +[Pandoc's manual](https://pandoc.org/MANUAL.html#tables). |
| 37 | + |
| 38 | + |
| 39 | +### Rendering the document |
| 40 | + |
| 41 | +Copy `tables-vrules.lua` in your document folder or in your pandoc |
| 42 | +data directory (details in |
| 43 | +[Pandoc's manual](https://pandoc.org/MANUAL.html#option--lua-filter)). |
| 44 | +Run it on your document with a `--luafilter` option: |
| 45 | + |
| 46 | +```bash |
| 47 | +pandoc --luafilter tables-vrules.lua SOURCE.md -o OUTPUT.pdf |
| 48 | + |
| 49 | +``` |
| 50 | + |
| 51 | +or specify it in a defaults file (details in |
| 52 | +[Pandoc's manual](https://pandoc.org/MANUAL.html#option--defaults)). |
| 53 | + |
| 54 | +This will generate Tables with vertical rules in Latex and PDF documents from Pandoc markdown source files. |
| 55 | + |
| 56 | +### Limitations |
| 57 | + |
| 58 | +This filter is active only for Latex and PDF output. |
| 59 | + |
| 60 | +Vertical rules in HTML documents should be handled via css styling. |
| 61 | + |
| 62 | +Contributing |
| 63 | +------------ |
| 64 | + |
| 65 | +PRs welcome. |
| 66 | + |
0 commit comments