【问题标题】:How do you add vertical lines in PDF tables generated with Pandoc如何在使用 Pandoc 生成的 PDF 表格中添加垂直线
【发布时间】:2014-03-25 15:19:56
【问题描述】:

有什么方法可以让 Pandoc 在不编辑 Pandoc 的源代码的情况下在 PDF 输出表中放置垂直线?

目前我正在使用以下方法生成 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"

【问题讨论】:

    标签: haskell pandoc


    【解决方案1】:

    目前没有办法添加垂直线,除了后处理 pandoc 的乳胶输出。据此https://github.com/jgm/pandoc/issues/922

    【讨论】:

    • 5 年后,这仍然是个问题。干得好,潘多克。