[英]Setting font size for markdown inline in jupyter notebook
I would like to set default font size and font type via code in line within a python notebook. 我想通过python笔记本中的代码设置默认字体大小和字体类型。
For example, I use this to set plot size defaults: 例如,我使用它来设置绘图大小默认值:
params = {'legend.fontsize': 'x-large','figure.figsize': (15, 10),'axes.labelsize': 'x-large','axes.titlesize':'x-large',
'xtick.labelsize':'x-large','ytick.labelsize':'x-large'}
pylab.rcParams.update(params)
I use this to set window width defaults 我用它来设置窗口宽度默认值
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
Is there a command that lets me set default markdown font to Arial size 24? 是否有一个命令允许我将默认降价字体设置为Arial大小24? Thank you!
谢谢!
MarkdownCell.render
can be patched to render markdown cells to a specified font size. 可以修补
MarkdownCell.render
以将markdown单元格渲染为指定的字体大小。
Dump the snippet below in a code cell and run. 将下面的代码段转储到代码单元格中并运行。
from IPython.core.display import Javascript, display
def set_markdown_font():
javascript = """
var _render = IPython.MarkdownCell.prototype.render;
if (_render.decorator === undefined) {
IPython.MarkdownCell.prototype.render = function () {
this.element.find('.rendered_html p').css('font-size', '30px');
return _render.apply(this, arguments);
}
IPython.MarkdownCell.prototype.render.decorator = true;
}
"""
display(Javascript(data=javascript))
set_markdown_font()
Edit 编辑
You can also target HTMLElement having .rendered_html
class and style them appropriately. 您还可以使用
.rendered_html
类定位HTMLElement并对其进行适当的样式设置。 I prefer this better (CSS over JS). 我更喜欢这个(CSS over JS)。
from IPython.core.display import display, HTML
display(HTML("<style>.rendered_html { font-size: 30px; }</style>"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.