3
votes

Is there any way to get Pandoc to put vertical lines in PDF output tables without editing Pandoc's source code?

Currently I'm generating PDF's using:

pandoc --template pandoc-template.tex -V geometry:margin=1in -V geometry:a4paper --number-sections --variable file1.md -o file1.pdf

The markdown for the table looks something like:

+-----------------+-----------------+
| Row 1           | Some data 1     |
| Row 2           | Some data 2     |
+-----------------+-----------------+

Pandoc simply ignores vertical lines. I've found multiple questions on this topic, but the answer remains illusive.

The Latex generated for the markdown above should probably look something like, where the pipe characters tells Latex to generate vertical lines for the table:

\begin{longtable}{ | l | l |}
  \hline                       
  Row 1 & Some data 1 \\
  Row 2 & Some data 2 \\
  \hline  
\end{longtable}

The code below is from the LaTex.hs Pandoc source file. I'm not a Haskell developer, but it does not seem to have an option to add the pipe characters required to create vertical lines in LaTex.

  let colDescriptors = text $ concat $ map toColDescriptor aligns
  modify $ \s -> s{ stTable = True }
  return $ "\\begin{longtable}[c]" <>
              braces ("@{}" <> colDescriptors <> "@{}")
              -- the @{} removes extra space at beginning and end
         $$ "\\toprule\\addlinespace"
         $$ headers
         $$ vcat rows'
         $$ "\\bottomrule"
         $$ capt
         $$ "\\end{longtable}"

toColDescriptor :: Alignment -> String
toColDescriptor align =
  case align of
         AlignLeft    -> "l"
         AlignRight   -> "r"
         AlignCenter  -> "c"
         AlignDefault -> "l"
1

1 Answers

3
votes

There is currently no way to add vertical lines, other than postprocessing pandoc's latex output. According to this https://github.com/jgm/pandoc/issues/922