如何在pandoc / markdown表中控制单元格宽度?

时间:2014-11-30 23:37:15

标签: markdown pandoc

有没有办法控制pandoc表中的最大单元格宽度?

例如:

|          |            |
|----------|------------|
| I want to the contents of this cell to fit on one line|   XXXXXXX  |

我想控制左边单元格中的线条是如何断开的,换句话说,我想控制单元格的最大宽度。

2 个答案:

答案 0 :(得分:17)

{CAVEATS:此答案仅适用于 Pandoc ,并且仅在使用Markdown语法中的输入的 multiline_table 扩展时。所以它不会为Github Flavored Markdown(GFM)工作。}


多行表确实支持列的 相对 宽度。 (但是,您将无法准确控制任何单元格中的行被打破的位置。)

查看我的answer to your other question

请注意,这仅适用于LaTeX,PDF和HTML输出,但不一定适用于HTML,ODT,DOCX或其他输出......


更新

以下是使用三个不同的多行表示例的示例。 它们在Markdown中的表头/内容的宽度各不相同 关注分隔线:

--------------------------------------------------------------------
Column 1                                                Column 2
------------------------------------------------------  ------------
I want the contents of this cell to fit into one line   Word1 Word2

------------------------------------------------------  ------------

: **Column 2 is narrow.** For column 1: 54 dashes in Markdown source 
for separator line; for column 2: 12 dashes in separator line (22% of column 1).


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Column 1                                                Column 2
------------------------------------------------------  ------------------------------------------------------------------------------------------------------------------------------------------------------------------
I want the contents of this cell to fit into one line   Word1 Word2

------------------------------------------------------  ------------------------------------------------------------------------------------------------------------------------------------------------------------------

: **Column 1 is narrow.** For column 1: 54 dashes in Markdown source for
separator line; for column 2: 162 dashes in separator line (300% of column 1).


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Column 1                                                                                                                                                                                                            Column 2
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ---------------
I want the contents of this cell to fit into one line                                                                                                                                                               Word1 Word2

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ---------------

: **Column 2 is even narrower than in Table 1.** For column 1: 210 dashes 
in Markdown source for separator line; for column 2: 15 dashes in separator 
line (7% of column 1).

<强>结果

  1. <强> PDF

    3 different tables as PDF from multiline-table Markdown

  2. HTML (没有使用太多样式表)

    3 different tables as HTML from multiline-table Markdown

答案 1 :(得分:1)

使用CuteMarkEd我可以在几次向标题raw或单元格(&nbsp;)中的字段添加非中断空格。