gpt4 book ai didi

Does not display Cyrillic in jupyter(未在jupyter中显示西里尔文)

转载 作者:bug小助手 更新时间:2023-10-28 21:56:53 24 4
gpt4 key购买 nike



I work in jupyter notebook and an error occurs when exporting a file to pdf. The Cyrillic alphabet is not displayed in the file. How to fix it?

我在jupyter笔记本上工作,在将文件导出为pdf时出现错误。西里尔字母表未显示在文件中。如何修复它?


I tried to create my own template, which is located in share\jupyter\nbconvert\templates\latex, but it didn't help.

我尝试创建我自己的模板,该模板位于Share\jupyter\nbConvert\Templates\LaTeX中,但没有帮助。


MyTemplate


更多回答

Welcome to Stack Overflow! Can you check if your template is being used by looking at the generated latex file?

欢迎来到Stack Overflow!您是否可以通过查看生成的LaTeX文件来检查您的模板是否正在使用?

what to do if it is not used

如果没有使用,该怎么办?

jupyter nbconvert notebook.ipynb --to latex --log-level DEBUG would show where jupyter looks for templates and resulting tex file would either contain your template directives or not.

jupyter nbconvert notebook.ipynb --to latex --log-level DEBUG将显示jupyter在哪里查找模板,生成的tex文件将包含或不包含模板指令。

I looked at debug, it shows the path in which the template is stored, but still the Cyrillic alphabet is not visible

我查看了调试,它显示了存储模板的路径,但仍然看不到西里尔字母表

You could specify your template file explicitly with jupyter nbconvert notebook.ipynb --to latex --template-file=share\jupyter\nbconvert\templates\latex\mytemplate.tex.j2. Also please post the contents of your template file verbatim instead of a screenshot.

您可以使用jupyter nbConver.ipynb--to LaTeX--template-file=share\jupyter\nbconvert\templates\latex\mytemplate.tex.j2.显式指定模板文件此外,请逐字张贴模板文件的内容,而不是屏幕截图。

优秀答案推荐

By default Jupyter uses XeLaTeX to compile latex files and to convert notebooks to PDF. XeLaTeX is an alternative LaTeX engine with inbuilt support of Unicode, while PDFLaTeX requires encoding tricks in order to emit characters in characters other than basic ASCII encoding.

默认情况下,Jupyter使用XeLaTeX编译LaTeX文件并将笔记本转换为PDF。XeLaTeX是一个内置Unicode支持的替代LaTeX引擎,而PDFLaTeX需要编码技巧才能发出基本ASCII编码以外的字符。


With XeLaTeX you do not need to load the fontenc package but you do need to ensure that the fonts XeLaTeX uses contain Cyrillic glyphs.

使用XeLaTeX,您不需要加载Fontenc包,但需要确保XeLaTeX使用的字体包含西里尔文字形。


Here is a modification of your template that uses Liberation fonts that contain Cyrillic letters. If you do not have these fonts (as you are probably on Windows) you might experiment with other fonts.

以下是对模板的修改,它使用了包含西里尔文字母的Liberation字体。如果您没有这些字体(因为您可能在Windows上),您可以尝试使用其他字体。


((=- Default to the notebook output style -=))
((*- if not cell_style is defined -*))
((*- endif -*))

((=- Inherit from the specified cell style. -=))
((* extends 'base.tex.j2' *))

((* block docclass *))
\documentclass{article}
((* endblock docclass *))

((* block maketitle *)) ((* endblock maketitle *))

((* block packages *))
((( super() ))) % load all other packages
\usepackage[english,russian]{babel}
\usepackage{mathtools}
\defaultfontfeatures{Ligatures={TeX},Renderer=Basic}
\setmainfont[Ligatures={TeX,Historic}]{Liberation Serif}
\setmonofont{Liberation Mono}
((* endblock packages *))

To try this template you may run the following commands from the command line:

要试用此模板,您可以从命令行运行以下命令:


jupyter nbconvert notebook.ipynb --to latex --template-file=./mytemplate.tex.j2
xelatex novosibirsk_stations.tex

更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com