0

i appear to be having a similar issue as described in other minted issue

however my issue differs that none of the solutions there work.

No matter how many times i uninstall/reinstall minted or miktex and pygments i still can not get it working. Removing the auxillary files also do not work and i keep getting the

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

enter image description here

my sample code is detailed here:

\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}

  • 2
    This does not seem to be a code issue. You should look into configuring TeXStudio to compile the document with the --shell-escape flag. This is because minted calls a Python program to generate the syntax highlighting. – olirwin Jul 06 '23 at 13:58

1 Answers1

2

The minted package calls a Python program to parse and highlight the source code you give it.

In order to allow the LaTeX compilator to call this program, you have to allow for "shell escapes". This is done by setting a flag on the compilation line.

From what I can gather, in TeXStudio, you can do this by going in

> Options > Configure TeXStudio, then Compilations then add the flag --shell-escape flag to the compilation command you are using.

olirwin
  • 295