如何在使用Pandoc生成的PDF表中添加垂直线

时间:2014-03-25 15:19:57

标签: haskell pandoc

有没有办法让Pandoc在PDF输出表中放置垂直线而不编辑Pandoc的源代码?

目前我正在使用以下方式生成PDF:

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

表格的缩写类似于:

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

Pandoc只是忽略了垂直线条。我发现了关于这个主题的多个问题,但答案仍然是虚幻的。

为上面的降价生成的Latex应该看起来像管道字符告诉Latex为表生成垂直线:

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

以下代码来自LaTex.hs Pandoc源文件。我不是Haskell开发人员,但它似乎没有选择添加在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 个答案:

答案 0 :(得分:1)

除了后处理pandoc的乳胶输出之外,目前无法添加垂直线。根据这个https://github.com/jgm/pandoc/issues/922