考虑以下代码:
\documentclass{minimal}
\usepackage[utf8x]{inputenc}
\usepackage{minted}
\usepackage{newunicodechar}
\newunicodechar{→}{\ensuremath{\to}}
\begin{document}
\begin{minted}{coq}
Require Import Utf8.
Check Set → Set.
\end{minted}
\end{document}
它输出一个包含以下内容的 PDF:
我不喜欢红色框;尽管代码是有效的 Coq,但它表示存在错误。我说这是一个错误,因为目录中_minted-...
有一个文件B9B79F25159396E029D998834CEDDFB4348AD1BE427E596276BBAC3B129C03FF.pygtex
,其内容是
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kn}{Require} \PYG{k+kn}{Import} \PYG{n+nn}{Utf8}\PYG{p}{.}
\PYG{n+nc}{Check} \PYG{k+kn}{Set} \PYG{err}{→} \PYG{k+kn}{Set}\PYG{o}{.}
\end{Verbatim}
我期望的颜色与我用以下方法替换时的颜色→
相同->
:
然后的代码538AF91E35E82BEEAFB959F2DD5440A2348AD1BE427E596276BBAC3B129C03FF.pygtex
是
\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kn}{Require} \PYG{k+kn}{Import} \PYG{n+nn}{Utf8}\PYG{p}{.}
\PYG{n+nc}{Check} \PYG{k+kn}{Set} \PYG{o}{\PYGZhy{}\PYGZgt{}} \PYG{k+kn}{Set}\PYG{o}{.}
\end{Verbatim}
所以我的问题是,我怎样才能获得\PYG{err}
替换\PYG{o}
?
如果相关的话,我的 pdflatex 和 pygmentize 版本是
$ pdflatex --version
pdflatex: warning: running with administrator privileges
MiKTeX-pdfTeX 2.9.6839 (1.40.19) (MiKTeX 2.9.6840 64-bit)
Copyright (C) 1982 D. E. Knuth, (C) 1996-2018 Han The Thanh
TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.6, 6-Sept-2010
compiled with curl version 7.56.1; using libcurl/7.56.1 WinSSL
compiled with expat version 2.2; using expat_2.2.0
compiled with jpeg version 9.2
compiled with liblzma version 50020032; using 50020032
compiled with libpng version 1.6.34; using 1.6.34
compiled with libressl version LibreSSL 2.5.3; using LibreSSL 2.5.3
compiled with MiKTeX Application Framework version 3.6802; using 3.6802
compiled with MiKTeX Core version 9.6844; using 9.6844
compiled with MiKTeX Archive Extractor version 1.6300; using 1.6300
compiled with MiKTeX Package Manager version 3.6833; using 3.6833
compiled with poppler version 0.60.1
compiled with uriparser version 0.8.4
compiled with zlib version 1.2.11; using 1.2.11
$ pygmentize.exe -V
Pygments version 2.0.2, (c) 2006-2014 by Georg Brandl.
pdflatex 日志可用就我的要点。根据 MiKTeX 控制台,我使用的是 minted v2.5(2017/07/19)。
答案1
\fcolorbox
我认为除了禁用内部之外没有其他办法minted
,看看https://tex.stackexchange.com/a/343506/4427
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usepackage{newunicodechar}
\usepackage{xpatch}
\newunicodechar{→}{\ensuremath{\to}}
\makeatletter
\AtBeginEnvironment{minted}{\dontdofcolorbox}
\def\dontdofcolorbox{\renewcommand\fcolorbox[4][]{##4}}
\xpatchcmd{\inputminted}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{}
\makeatother
\begin{document}
\begin{minted}{coq}
Require Import Utf8.
Check Set → Set.
\end{minted}
\end{document}
但我得到的颜色不同。
请注意,不适newunicodechar
用于utf8x
;尽管如此,您还是会得到箭头,因为utf8x
为提供了定义→
。
Package newunicodechar Warning: This package only works if the document
(newunicodechar) encoding is `utf8'.