数学在铸币厂:奇怪的间距

数学在铸币厂:奇怪的间距

我正在使用该minted包在 LaTeX 中显示代码。我想在注释中插入一个数学公式,但公式看起来很奇怪。≤ 符号前后的空间比预期的多得多:

()

如你所见,上面的“1≤n≤100”是我想要的间距,但注释中的“1≤n≤100”似乎间距太大。我该如何解决这个问题?谢谢。

我的代码:

\documentclass{article}
\usepackage{minted}
\begin{document}
$1\le n\le 100$.
\begin{minted}[mathescape,baselinestretch=1]{python}
def a(n) :
    return 1 <= n && n <= 100 # $1 \le n\le 100$
\end{minted}
\end{document}

编辑:我在 Windows 10 上,使用 CTeX、WinEdt 7.0。这是 PDFTeXify 的输出。希望这有帮助。

Command Line:   bibtex.exe "tmp"
Startup Folder: F:\tmp

This is BibTeX, Version 0.99d (MiKTeX 2.9)
The top-level auxiliary file: tmp.aux
I found no \citation commands---while reading file tmp.aux
I found no \bibdata command---while reading file tmp.aux
I found no \bibstyle command---while reading file tmp.aux
(There were 3 error messages)


Command Line:   texify.exe --pdf --tex-option=--shell-escape --tex-option=--interaction=errorstopmode --tex-option=--synctex=1 "F:\tmp\tmp.tex"
Startup Folder: F:\tmp

This is pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9)
entering extended mode
(F:/tmp/tmp.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for loaded.
(C:\CTEX\MiKTeX\tex\latex\base\article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(C:\CTEX\MiKTeX\tex\latex\base\size10.clo))
(C:\CTEX\MiKTeX\tex\latex\minted\minted.sty
(C:\CTEX\MiKTeX\tex\latex\graphics\keyval.sty)
(C:\CTEX\MiKTeX\tex\latex\fancyvrb\fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 
<2008/02/07> (tvz)) (C:\CTEX\MiKTeX\tex\latex\xcolor\xcolor.sty
(C:\CTEX\MiKTeX\tex\latex\00miktex\color.cfg)
(C:\CTEX\MiKTeX\tex\latex\pdftex-def\pdftex.def
(C:\CTEX\MiKTeX\tex\generic\oberdiek\infwarerr.sty)
(C:\CTEX\MiKTeX\tex\generic\oberdiek\ltxcmds.sty)))
(C:\CTEX\MiKTeX\tex\latex\float\float.sty)
(C:\CTEX\MiKTeX\tex\latex\base\ifthen.sty)
(C:\CTEX\MiKTeX\tex\latex\tools\calc.sty)
(C:\CTEX\MiKTeX\tex\latex\ifplatform\ifplatform.sty
(C:\CTEX\MiKTeX\tex\generic\oberdiek\pdftexcmds.sty
(C:\CTEX\MiKTeX\tex\generic\oberdiek\ifluatex.sty)
(C:\CTEX\MiKTeX\tex\generic\oberdiek\ifpdf.sty))
(C:\CTEX\MiKTeX\tex\generic\oberdiek\catchfile.sty
(C:\CTEX\MiKTeX\tex\generic\oberdiek\etexcmds.sty))))找不到 F:\tmp\tmp.aex

F:\tmp>set  /p x=C:\Python27\Scripts\pygmentize.exe 0<nul: 1>>tmp.aex 

F:\tmp>set  /p x= 0<nul: 1>>tmp.aex 

F:\tmp>set  /p x= 0<nul: 1>>tmp.aex 

file deleted
(F:\tmp\tmp.aux) (C:\CTEX\MiKTeX\tex\context\base\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (F:\tmp\tmp.pyg) (F:\tmp\tmp.out.pyg) [1{C:/CTEX/UserData/pdftex/config/pdfte
x.map{Unicode.sfd}{UGBK.sfd}}] (F:\tmp\tmp.aux) )<C:/CTEX/MiKTeX/fonts/type1/pu
blic/amsfonts/cm/cmitt10.pfb><C:/CTEX/MiKTeX/fonts/type1/public/amsfonts/cm/cmm
i10.pfb><C:/CTEX/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/CTEX/MiKTe
X/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/CTEX/MiKTeX/fonts/type1/public/
amsfonts/cm/cmtt10.pfb>
Output written on tmp.pdf (1 page, 40459 bytes).
SyncTeX written on tmp.synctex.gz.
Transcript written on tmp.log.


_____________________________________________________________________

 PDFTeXify Compilation Report (Pages: 1)

 Errors: 0   Warnings: 0   Bad Boxes: 0
_____________________________________________________________________

PS 也许我应该minted在这里放我的版本?但我如何查看我的minted版本?

编辑2:我的python版本是2.7.12。

答案1

在旧版本的 中mintedmathescape其行为在很多方面与普通数学模式并不完全相同,包括对空格的处理。较新版本的minted(2.3 及更高版本)会加载fvextra,这会导致mathescape的行为更符合预期。

根据您的日志,fvextra未加载,因此您可能正在使用旧版本的minted。更新应该可以解决此问题。

相关内容