带有HTML边框的表和Pandoc标记源的LaTeX输出

带有HTML边框的表和Pandoc标记源的LaTeX输出,html,pdf,latex,markdown,pandoc,Html,Pdf,Latex,Markdown,Pandoc,这是Pandoc的降价示例表 Simple tables look like this: Right Left Center Default ------- ------ ---------- ------- 12 12 12 12 123 123 123 123 1 1 1 1 Table:

这是Pandoc的降价示例表

Simple tables look like this:

  Right     Left     Center     Default
-------     ------ ----------   -------
     12     12        12            12
    123     123       123          123
      1     1          1             1

Table:  Demonstration of simple table syntax.
不幸的是,它没有添加边界

我可能将其编码为HTML表,但在本例中,它在LaTeX中不起作用

  • 如何创建一个带有边框的表,同时使用LaTeX和HTML输出

  • 如果Pandoc无法完成这项工作,是否有类似的工具能够完成


使用Pandoc时,以下CSS会将表格添加到HTML输出中:

table {
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 24px;
    border-spacing: 0;
    border-bottom: 2px solid black;
    border-top: 2px solid black;
}
table th {
    padding: 3px 10px;
    background-color: white;
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid black;
}
table td {
    padding: 3px 10px;
    border-top: none;
    border-left: none;
    border-bottom: none;
    border-right: none;
}


/* Add border for the last row of the table.           */
/*      (Might be of use for table footnotes, later).  */
/* tr:last-child td { border-top: 2px solid black; }   */
此CSS来自Marked.app。我相信可以在应用程序的上下载

您可以告诉Pandoc使用带有
--CSS
标志的自定义CSS文件。像这样的方法应该会奏效:

pandoc -t html                      \
       --css=/path/to/custom.css    \
       -o /path/to/output/file.html \
        /path/to/markdown/file.md

希望能有所帮助。

你可以用Pandoc来做。但这需要更多的努力

您必须利用以下事实:

  • Pandoc可以识别嵌入Markdown[1]中的原始乳胶片段。如果目标输出格式是LaTeX或PDF,它会将这些代码段原封不动地传递到目标文档中

    因此,如果您知道如何用LaTeX编写一个好看的表,请将其与降价一起嵌入

    但是,对于HTML输出,此LaTeX表代码将被忽略。这不是问题,因为

  • Pandoc可以识别嵌入Markdown[1]中的原始HTML片段。如果目标输出格式是HTML,它会将这些代码段原封不动地传递到目标文档中

    因此,如果您知道如何在HML中编写一个外观良好的表,请将它与您的降价一起嵌入

    但是,对于LaTeX/PDF输出,此HTML表格代码将被忽略。这不是问题,因为

  • Pandoc可以识别嵌入Markdown[1]中的原始乳胶片段。。。。(啊啊哈!我们已经有了。请看上面的编号:)


  • 技巧:在终端窗口中交互使用
    pandoc
    还有一个窍门

    如果你不知道如何开始学习乳胶,潘多克可以教你一些。因为您可以交互使用Pandoc

    对于乳胶输出:

    事情是这样的:

  • 在终端中键入:
    pandoc-t latex
  • 点击
    [返回]
  • 什么也没发生
  • 开始在终端中键入标记代码段(就像在文本编辑器中键入标记代码一样)。喂,你打一张表
  • 当您的表格准备好后,再点击一次
    [RETURN]
    即可进入换行
  • 然后点击
    [CTRL]+[D]
  • 瞧!,LaTeX代码出现在终端窗口中
  • 请看这里:

    $ pandoc -t latex   [RETURN]
    
      Right     Left     Center     Default
    -------     ------ ----------   -------
         12     12        12            12
        123     123       123          123
          1     1          1             1
    
    Table:  Demonstration of simple table syntax.
    
    ^D
    
    老实说:我没有打降价表。 我作弊了。 我把你的问题抄下来贴在终端上。 您看到的最后一个
    [^D]
    是当我点击
    [CTRL]+[D]

    这是终端窗口中显示的内容:

    \begin{longtable}[c]{@{}rlcl@{}}
    \caption{Demonstration of simple table syntax.}\tabularnewline
    \toprule
    Right & Left & Center & Default\tabularnewline
    \midrule
    \endfirsthead
    \toprule
    Right & Left & Center & Default\tabularnewline
    \midrule
    \endhead
    12 & 12 & 12 & 12\tabularnewline
    123 & 123 & 123 & 123\tabularnewline
    1 & 1 & 1 & 1\tabularnewline
    \bottomrule
    \end{longtable}
    
    这是LaTeX从标记输入生成的默认LaTeX表代码

    现在你可以在谷歌上搜索一些方法(如果你还不是乳胶专家的话)来拉皮条,以使桌子看起来更漂亮。繁重的工作已经完成了。(如果你是一名乳胶专家:不用自己做举重也是件好事,不是吗?)

    对于HTML输出:

    当然,您可以像Pandoc生成表格一样输出表格的HTML代码。看:

    $ pandoc -t html   [RETURN]
    
      Right     Left     Center     Default
    -------     ------ ----------   -------
         12     12        12            12
        123     123       123          123
          1     1          1             1
    
    Table:  Demonstration of simple table syntax.
    
    ^D
    
    <table>
    <caption>Demonstration of simple table syntax.</caption>
    <thead>
    <tr class="header">
    <th align="right">Right</th>
    <th align="left">Left</th>
    <th align="center">Center</th>
    <th align="left">Default</th>
    </tr>
    </thead>
    <tbody>
    <tr class="odd">
    <td align="right">12</td>
    <td align="left">12</td>
    <td align="center">12</td>
    <td align="left">12</td>
    </tr>
    <tr class="even">
    <td align="right">123</td>
    <td align="left">123</td>
    <td align="center">123</td>
    <td align="left">123</td>
    </tr>
    <tr class="odd">
    <td align="right">1</td>
    <td align="left">1</td>
    <td align="center">1</td>
    <td align="left">1</td>
    </tr>
    </tbody>
    </table>
    
    $pandoc-t html[返回]
    左右中心默认值
    -------     ------ ----------   -------
    12     12        12            12
    123     123       123          123
    1     1          1             1
    表:简单表语法的演示。
    ^D
    演示简单的表语法。
    赖特
    左边
    居中
    违约
    12
    12
    12
    12
    123
    123
    123
    123
    1.
    1.
    1.
    1.
    
    那不是很好吗



    [1]在处理降价输入时,您可能需要告诉Pandoc您想使用它的一些扩展名:
    Pandoc--from=Markdown+raw\u html+raw\u tex+…
    ,以防它在默认设置下无法工作……

    “它没有添加”:很抱歉,这是一个输入错误,但我需要它们。请根据偶尔阅读的提示更新您的答案:它仍然没有在表内显示边框,因为您可以将
    border-*
    变量从
    none
    设置为,例如,
    1px
    。是否可以将标记转换为PDF格式(其中标记包含嵌入的HTML片段)一次性?@cmcdragokai:如果你使用Pandoc,嵌入的HTML只会传递到基于HTML的输出格式(HTML、HTML5、EPUB、EPUB3、DZSlides、slidey、Slideous、RevealJS等),而对于LaTeX或PDF输出则会被忽略。我不知道还有任何其他降价转换工具可以处理您的请求。
    为了使桌子看起来更漂亮,我想向皮条客兜售该代码。
    ——感谢您显示交互式模式——非常酷。但是,关于边框,我不知道如何在标记中插入LaTeX片段来设置垂直边框。它将出现在
    \begin{longtable}[c]{{{rlcl}}
    行中,对,使用
    \begin{longtable}[c]{{{r}l{124; c{124; l}}
    ——如果没有这个帮助,答案的乳胶部分最终不会有多大用处。