簡體   English   中英

Nbconvert:如何更改輸出 pdf/html 中代碼單元格的字體?

[英]Nbconvert: How to change font of code cells in the output pdf/html?

我正在使用 nbconvert 將 jupyter notebook 文件轉換為 html 和/或 pdf。 使用下面的自定義模板,jupyter notebook 中的 Markdown 文本都是 Arial; 但是,使用 print 語句從代碼單元創建的文本是不同的字體。 如何將輸出文本的字體從例如print("This is my code")更改為 Ariel? 在下面的代碼中,我試圖只制作所有文本 Arial。

我的 index.html.j2

{%- extends 'lab/index.html.j2' -%}

{%- block html_head_css -%}
  {{ super() }}
  <style>
    @font-face {
      font-family: Arial, Helvetica, sans-serif;
      font-style: normal;
      font-weight: 400;
    }
    h1, h2, h3 {
      font-family: Arial, Helvetica, sans-serif;
    }
    .header {
      overflow: hidden;
      # background-color: #f1f1f1;
      # padding: 20px 10px;
    }
    .logo-container {
      # margin: auto;
      # width: fit-content;
      text-align:left;
      width:50px;
    }
    body {
      font-family: Arial, Helvetica, sans-serif;
    }
  </style>
{%- endblock html_head_css -%}

{% block body_header %}
  <body class="jp-Notebook theme-light" style="padding: 0; margin: 0;">
  <div class="header">
    <div class="logo-container width:50px;">
    <img src="myimage.png">
    </div>
  </div>
  <div style="padding: 20px; margin: 20px;">
{% endblock body_header %}

{% block body_footer %}
  </div>
  </body>
{% endblock body_footer %}

第一行是降價單元格,第二行是打印語句的輸出

我剛剛添加了以下內容,它現在正在工作。

* {
   font-family: Arial, Helvetica, sans-serif;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM