markdown - Markdown 中的表格(在 Jupyter 中)

标签 markdown jupyter

一个 super 基本的问题:为什么以下内容没有在 Markdown 中呈现 - 恰好在 jupyter 中笔记本

原始码

### Results

| --- | --- | --- |
| Stretch/Untouched | ProbDistribution | Accuracy |
| --- | --- | --- |
| Stretched | Gaussian | .843 |

代码在 jupyter 中的样子处于编辑模式

enter image description here

渲染于 jupyter

enter image description here

所以表格没有正确呈现

更新 我做了一些摆弄,现在它呈现..但是 仍然不确定为什么原始代码不起作用

enter image description here

最佳答案

表格的第一行定义标题,然后下一行定义每列的对齐方式。您复制了表格顶部的对齐方式以及它实际应该去的位置。
正确的 Markdown 应该只是你的语法,但删除第一行:

| Stretch/Untouched | ProbDistribution | Accuracy |
| --- | --- | --- |
| Stretched | Gaussian | .843 |
---在列定义之间 | |意味着该列是不合理的。在标准 Markdown 中,这将与列的左侧对齐,但在 Jupyter notebook 中,它似乎与右侧对齐。
有了这个,我得到了这张表:
enter image description here

如果你想左对齐或居中对齐,你可以使用 :-:-:分别。根据您使用的 Jupyter 笔记本环境,您需要使用 -:右对齐。
| Stretch/Untouched | ProbDistribution | Accuracy |
| :- | -: | :-: |
| Stretched | Gaussian | .843
第一列左对齐,中心列右对齐,最后一列居中对齐。有趣的是使用 Google Colab,---左对齐文本:
enter image description here

您的 Jupyter 笔记本中的对齐方式是否未按预期工作?
不幸的是,当使用 Jupyter 笔记本环境的本地安装时,我上面提到的对齐语法在此日期(2020 年 6 月 25 日)不起作用。这是因为 Jupyter 源代码中存在一个错误,即未考虑 Markdown 对齐并且所有文本都右对齐。在此处查看 Github 问题:https://github.com/jupyter/notebook/issues/3919 .但是,它确实可以使用 jupyterlab 以及在 Google Colab 上工作。

关于markdown - Markdown 中的表格(在 Jupyter 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48655801/

相关文章:

r - 创建参数化 R Markdown 文档?

r - 修改 r 笔记本中的参数

wiki - 我应该为Wiki格式的文本文件使用标准的内容(MIME)类型吗?

python - python 中颜色空间的 3D 表面图

python - 可视化一列中的数据

ipython - 自动化标准的 jupyter/ipython 笔记本导入

pdf - 使用 pandoc 将所有 yaml 书目导出为 pdf 文件

Markdown - 带有 :colons:? 的图像

jupyter-notebook - 错误 conda.core.link :_execute(700): An error occurred while installing package 'conda-forge::jupyter_nbextensions_configurator-0.4.1-py37_0'

python - 如何在 %sql 查询中使用 python 列表