带有Pandoc的Markdown源的HTML和LaTeX输出中的边界表 [英] Table with borders in HTML and LaTeX output from Markdown source with Pandoc

查看:204
本文介绍了带有Pandoc的Markdown源的HTML和LaTeX输出中的边界表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是Pandoc Markdown中的示例表。

 简单表格如下所示:

右侧中心默认
---- --- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1

表格:演示简单的表格语法。

不幸的是不添加边界。

我可能会将其编码为HTML表格,但在这种情况下,它在LaTeX中不起作用。




  • 如何制作带有LaTeX和HTML输出的边框的表格?


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

  • 下面的CSS添加了表格在使用Pandoc时输出到HTML输出:

     表格{
    margin-left:auto;
    margin-right:auto;
    margin-bottom:24px;
    border-spacing:0;
    border-bottom:2px纯黑色;
    border-top:2px纯黑色;
    }
    table th {
    padding:3px 10px;
    背景颜色:白色;
    border-top:none;
    border-left:none;
    border-right:none;
    border-bottom:1px纯黑色;
    }
    table td {
    padding:3px 10px;
    border-top:none;
    border-left:none;
    border-bottom:none;
    border-right:none;
    }


    / *为表格的最后一行添加边框。 * /
    / *(稍后可能用于表格脚注)。 * /
    / * tr:last-child td {border-top:2px纯黑色; } * /

    这个CSS来自Marked.app。我相信它可以在支持网站撰写自定义CSS。



    您可以告诉Pandoc使用 - css 标志的自定义CSS文件。像这样的东西应该可以工作:

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

    希望有所帮助。


    This is a sample table in Markdown for 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.
    

    It does not add borders unfortunately.

    I might code it as an HTML table, but in this case it will not work in LaTeX.

    • How can I make a table with borders working both with LaTeX and HTML output?

    • If Pandoc can't do the job, is there a similar tool which is able to?

    解决方案

    The following CSS adds tables to your HTML output when using Pandoc:

    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; }   */
    

    This CSS is from Marked.app. I believe it's available to download on the support website for the app.

    You can tell Pandoc to use a custom CSS file with the --css flag. Something like this should work:

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

    Hope that helps.

    这篇关于带有Pandoc的Markdown源的HTML和LaTeX输出中的边界表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆