Minted 无法运作

Minted 无法运作

我正在尝试在 Windows 8 上使用 minted 包。我安装了 python 和 Pygment,并在我的路径上添加了 C:\Python34 和 C:\Python34\Scripts。

当我尝试编译以下乳胶代码时:

\documentclass[12pt,a4paper]{report}
\usepackage[pdftex]{graphicx} %for embedding images
\usepackage[francais]{babel}
\usepackage{eurosym}
\usepackage{pdftexcmds}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\usepackage{url} %for proper url entries
\usepackage{minted}

\begin{document}

\input{./a.tex}
\input{./b.tex}
\input{./h.tex}

输入命令的一个文件包含以下代码:

\begin{minted}{csharp}

string test;

\end{minted}

我收到以下错误,这些错误对我来说没有任何意义:

\openout3 = `report.pyg'.
runsystem(pygmentize -l csharp -f latex -F tokenmerge -P style=default -P comma
ndprefix=PYGdefault -o "_minted-report/B3A3E546A80461696602265F0BBFCFE46439C04D
9C5223188E498C03CB02681D.pygtex" "report.pyg" )...executed.
(./_minted-report/B3A3E546A80461696602265F0BBFCFE46439C04D9C5223188E498C03CB026
81D.pygtex
! Undefined control sequence.
<argument> \PYGdefault
{k+kt}{string} \PYGdefault {n}{test}\PYGdefault {p}{;}
l.2 ...ring} \PYGdefault{n}{test}\PYGdefault{p}{;}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
<argument> \PYGdefault {k+kt}{string} \PYGdefault
{n}{test}\PYGdefault {p}{;}
l.2 ...ring} \PYGdefault{n}{test}\PYGdefault{p}{;}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
<argument> ...g} \PYGdefault {n}{test}\PYGdefault
{p}{;}
l.2 ...ring} \PYGdefault{n}{test}\PYGdefault{p}{;}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

答案1

我现在可以确认这个问题了。在我的本地机器上不可能重现这个错误,但在另一台机器上我成功了。

我已尝试过如下方法。

  1. 安装python2.7和pygmentize
  2. 没有添加路径并进行编译(_minted-exampleb 自动创建为子目录)但是我出现上述消息并失败。
  3. 安装python3.4和pygmentize
  4. 向 windowsenvironment 添加了正确的路径并尝试编译,但也失败了。
  5. 删除所有临时文件并再次编译。成功。(pdf 编译正确)(包括 _minted-%filname%)

在我看来,有些旧文件或路径设置可能无法访问相同版本的 python,并且旧文件仍然在示例文件夹中。

我在 Windows 7 上工作,也许这个问题与操作系统无关,那么您应该尝试删除所有旧的 python2.7 安装并删除 examplefolder 的所有旧临时文件。

我不确定,但我认为值得尝试一下。

答案2

我在包含 minted 时也收到错误消息。我尝试了很多不同的方法,但最终解决我问题的方法是将 minted ( \usepackage{minted}) 作为第一个包。

相关内容