Minted 不工作包错误 shell 转义

Minted 不工作包错误 shell 转义

我似乎遇到了与描述类似的问题 其他铸造问题

然而我的问题不同,那里的解决方案都不起作用。

无论我卸载/重新安装 minted 或 miktex 和 pygments 多少次,我仍然无法让它工作。删除辅助文件也不起作用,我不断得到

Package minted Error: You must invoke LaTeX with the -shell-escape flag. \usepackage error

在此处输入图片描述

我的示例代码详细说明如下:

\usepackage{subcaption} %This is to have multiple sub figures in a single figure
\usepackage{enumitem}%This is for Lists and adjusting the spacing between bullets
\setlist{nosep,leftmargin=*}%This is for Lists and removing the spacing between bullets
%\usepackage[labelformat=parens,labelsep=quad,skip=3pt]{caption}
\usepackage{multirow} %This is for multirow tables
\usepackage{makecell} %Allows line breaks in tables with \thead{} command 
\usepackage{tabularx} %Better Table Format
\usepackage{booktabs} %Better Table Format
\usepackage{listings} %alternative method of inserting code
\usepackage[cache=false]{minted} %This is to print out code nicely
%Referencing
\usepackage[backend=biber,style=ieee]{biblatex} %Bibliography and citation
\addbibresource{C:/Users/66smi/OneDrive/University of Pretoria/Zotero/MyZoteroLibrary.bib}
%Commenting
\usepackage[colorinlistoftodos]{todonotes}%This allows for comments to appear on the PDF
\usepackage{easyReview}
%Hyperlinks and Linking - note this package often has to be the last import
\usepackage{hyperref}
\hypersetup{
    colorlinks= false,
    linkcolor= black,
    linkbordercolor = 0 0 0,
    filecolor=black,
    citecolor = black,
    urlcolor=black,
    colorlinks=true,
    linkcolor=blue,
    %citebordercolor = 0 1 0,
%   citecolor = green,
%   filecolor=magenta, 
%   urlcolor = cyan,
    %allcolors = blue,     
    %urlcolor=cyan,
}
%document headings
\title{Latex Report Template}
\author{Justin Smith}

\begin{document}
\singlespacing %single line spacing
%Cover Page
%If a specific Front Matter Is desired
%Option 1
%\maketitle
%\textbf{This page represents the cover page}\newline
%\textit{Report will begin here}
%\thispagestyle{empty}
%\pagebreak
%end option 1
%Option 2
%\setcounter{secnumdepth}{0} %this command can remove all the section numbers from the article
%document headings
\begin{center}
{\Huge Title} \\[18pt]
{\LARGE  Sub-Title } \\[18pt]
{\LARGE Smith J, 19065320 }\\[18pt]
{\LARGE \today} \\[18pt]
\end{center}
%Plagiarism Declaration
\textbf{It is hereby declared that this is my own work and appropriate reference has been made to other people’s work (e.g. indicate at each question with whom you discussed the question.)}
\thispagestyle{empty} %This removes the page number from the cover page
%End Plagiarism Declaration
\pagebreak
%End Option 2

%Executive Summary
\section*{Executive Summary}
Here lies the Executive summary which is before the table of contents.

\setcounter{page}{0}
\pagenumbering{roman}
\pagebreak
%End Exec Summary

%Table of Contents
\renewcommand*\contentsname{Table Of Contents}
\addcontentsline{toc}{section}{Executive Summary}
\tableofcontents 
\addcontentsline{toc}{section}{Reference List}
\newpage
%End Table of Contents

%Main Body Formatting
\setcounter{page}{0}
\pagenumbering{arabic}
%End Main Body Formatting
\pagebreak

%Introduction
\section{Introduction}
The introduction for the report will be inserted here

\pagebreak
%Reference List
\section{References List}
\printbibliography[heading=none]
%End Reference List
\pagebreak

\appendix
\section{Appendix}

\subsection{Code Example}
\begin{minted}[breaklines=true]{python}
    import numpy as np
    
    def incmatrix(genl1,genl2):
    m = len(genl1)
    n = len(genl2)
    M = None #to become the incidence matrix
    VT = np.zeros((n*m,1), int)  #dummy variable
    
    #compute the bitwise xor matrix
    M1 = bitxormatrix(genl1)
    M2 = np.triu(bitxormatrix(genl2),1) 
    
    for i in range(m-1):
    for j in range(i+1, m):
    [r,c] = np.where(M2 == M1[i,j])
    for k in range(len(r)):
    VT[(i)*n + r[k]] = 1;
    VT[(i)*n + c[k]] = 1;
    VT[(j)*n + r[k]] = 1;
    VT[(j)*n + c[k]] = 1;
    
    if M is None:
    M = np.copy(VT)
    else:
    M = np.concatenate((M, VT), 1)
    
    VT = np.zeros((n*m,1), int)
    
    return M
\end{minted}
%End Appendix
\end{document}

答案1

minted包调用一个 Python 程序来解析并突出显示您提供的源代码。

为了让 LaTeX 编译器能够调用这个程序,你必须允许“shell escapes”。这可以通过在编译行上设置一个标志来实现。

据我所知,在 TeXStudio 中,您可以通过以下方式执行此操作:

> Options > Configure TeXStudio,然后Compilations将标志--shell-escapeflag添加到您正在使用的编译命令中。

相关内容