如何控制pandoc/markdown表中的单元格宽度? [英] How to control cell width in pandoc/markdown table?

查看:145
本文介绍了如何控制pandoc/markdown表中的单元格宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a way to control the maximum cell width in a pandoc table?

例如:

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

我想控制左侧单元格中的线是如何折断的,换句话说,我想控制单元格的最大宽度.

I want to control how the line in the left cell is broken or, in other words, I want to control the maximum width of a cell.

推荐答案

{注意:此答案仅适用于 Pandoc ,并且仅当使用 multiline_table Markdown语法中输入的扩展名.因此,它不适用于Github风味降价(GFM).}

{CAVEATS: This answer applies to Pandoc only, and only when making use of the multiline_table extension to the input in the Markdown syntax. So it won't work for Github Flavored Markdown (GFM).}

多行表格确实支持列的 相对 宽度. (但是,您将无法精确控制任意单元格中的行的断开位置和方式.)

Multiline tables do support the relative width of columns. (However, you will not be able to control exactly where + how the line in any cell is broken.)

请参阅我对另一个问题的答案.

See my answer to your other question.

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

Be aware that this works for LaTeX, PDF and HTML output only, but not necessarily for HTML, ODT, DOCX or other output...

这里是一个示例,其中使用了三个不同的多行表示例. 它们在Markdown中的变化取决于表头/内容的宽度 有关分隔线:

Here is an example, using three different examples of multiline tables. They vary in Markdown as far as the widths of their table header/content separator lines are concerned:


--------------------------------------------------------------------
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

  1. PDF

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

HTML (without much of a stylesheet used)

这篇关于如何控制pandoc/markdown表中的单元格宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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