如何更改 iPython Notebook 中特定单元格的背景颜色?例如,我正在编写一本手册,我想在灰色文本框中添加一些终端命令,如下所示http://ipython.org/ipython-doc/1/interactive/nbconvert.html http://ipython.org/ipython-doc/1/interactive/nbconvert.html.
基本上,您可以在 Markdown 单元格内的预格式化代码块中编写终端命令。
对于单行(内联)代码,您可以使用双坟墓(``),例如echo 1
(``回声1``)。这与 Stackoverflow 上的工作原理完全相同。
较长的代码片段(带有语法突出显示)可能更好地放置在受隔离的代码块中,例如
```bash
for i in *.jpg; do
display $i
done
```
here, bash specifies the syntax color. This renders in IPython 2.x like
If you want a different background style, you can use CSS styles. E.g. add the following lines in a code cell, or better (slightly adapted) to your custom.css.
%%html
<style type="text/css">
.rendered_html code {
background-color:#E8E8E8;
padding: 3px;
};
</style>
With this the preformatted code looks like
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)