在 Marp 中插入表格

问题描述 投票:0回答:2

我正在使用 Marp 生成 pdf 演示文稿(markdown 语法)。 对于演示文稿,我必须从 pandas 数据框中插入表格。 我现在使用的技巧是通过 pandas 打印“to_markdown”并将结果复制粘贴到我的 Markdown 代码中,但我无法更改字体大小并选择放置表格的位置。 Marp documentation 对于此类问题没有太大帮助。 如何在 Markdown 中修改字体大小和表格本地化?

pandas markdown presentation marp
2个回答
5
投票

您可以通过样式属性的可用性以任何您想要的方式设置表格样式(全局或仅限于单张幻灯片)。

例如,您可以使用 Markdown 表格并通过调整必要的 CSS 选择器来更改其外观。默认情况下,这将全局应用,但如果您在

scoped
标签后添加
style
,那么它将仅作用于该幻灯片。 (有关更多信息,请参阅 marp 文档)。

这允许您为表格设置各种样式 - 甚至设置可以根据需要对每张幻灯片进行调整的通用样式。

请参阅下面的示例。


---
marp: true
theme: default
---

<style scoped>
table {
    height: 100%;
    width: 100%;
    font-size: 20px;
    color: red;
}
th {
    color: blue;
}
</style>

# Fruit Table -- styled

Fruit | Colour | Amount | Cost
-----|------|:-----:|------:
Banana | Yellow | 4 | £1.00
Apple | Red | 2 | £0.60
Orange | Orange | 10 | £2.50
Coconut | Brown | 1 | £1.50

---

# Fruit Table -- default

Fruit | Colour | Amount | Cost
-----|------|:-----:|------:
Banana | Yellow | 4 | £1.00
Apple | Red | 2 | £0.60
Orange | Orange | 10 | £2.50
Coconut | Brown | 1 | £1.50


0
投票

使用 VS Code 扩展,

"markdown.marp.enableHtml": true
+ html 表格对我有用。

<!-- requires  "markdown.marp.enableHtml": true -->
<table>
<tr>
<th> .NET runtime</th>
<th> .NET SDK </th>
<tr><td>

  * Serialization
  * LINQ
  * Collections
  * Cryptography
  * Reflection
  * Performance

</td><td style="vertical-align: top;">

   * Unit testing
   * .NET tool roll-forward
</td></tr>
</table>

->

© www.soinside.com 2019 - 2024. All rights reserved.