首页 > 解决方案 > 在 jupyter 笔记本上对齐行号

问题描述

  1. 问题:行号与单元格内的代码重叠。左边有足够的空间放置数字,但我不知道如何对齐它们。行号重叠

  2. 上下文:我更新了我的主题,以使其在 jupyter 主题!jt -t gruvboxl -f fira -fs 14 -nf ptsans -nfs 14 -N -kl -cursw 2 -cursc r -cellw 95% -T -ofs 14 -dfs 11 代码的帮助下更加舒适,以防万一。

  3. 可能的原因:折叠代码(函数,循环)的笔记本扩展+行号+字体大小随着jupyter主题的增加都可能相互争斗。

  4. TLDR:如何操作行号扩展以对齐左侧的数字?

标签: jupyter-notebookjupyter

解决方案


I got it. Not a CSS expert so maybe I broke something terribly and it will come back to bite me where I get my injections. Anyway, I added this to .jupyter\custom\custom.css:

div.CodeMirror-linenumber.CodeMirror-gutter-elt {
    left: 10px !important;
}
pre.CodeMirror-line {
    left: 2px !important;
}

推荐阅读