【发布时间】: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"
【问题讨论】: