1

I am trying to use the listings package to show code in my document, but for some reason, if I include this package, the whole document doesn't compile. I don't get any error messages, just:

Process started: pdflatex.exe -synctex=1 -interaction=nonstopmode "test".tex

Process exited normally But the document would not update.

My code is simple:

\documentclass[]{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
    test
\end{lstlisting}
\end{document}

If I remove \usepackage{listings} as well as the \begin{lstlisting} block, I am able to compile the document normally.

I am using TeXstudio 4.3.1 with MiKTeX (all packages updated).

The same problem happens with other packages that depend on listings (such as mcode and matlab-prettifier mentioned in this post): What can I use to typeset MATLAB code in my document?

When I try to use the minted package (code below):

\documentclass[]{article}
\usepackage{minted}
\begin{document}
\begin{minted}{python}
    test
\end{minted}
\end{document}

I get the following error messages:

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

Emergency stop. \begin{document}

shell escape is disabled, so I can only detect \ifwindows.

I have no issues using verbatim, however, but it does not give me the line wrapping feature I need.

  • 1
    Welcome to TeX.SE! – Mensch Nov 16 '22 at 17:25
  • 1
    The minted package documentation, minted says that -shell-escape needs to be added because the minted package calls external sources to process the code in Latex. If this is not something that would be preferred then using verbatim would be the option with the least configuration changes required. – Leucippus Nov 16 '22 at 19:02
  • The furst MWE runs fine on my system. Place the curso; over the TeXstudio icon and see if you have two runs going at the same time. – John Kormylo Nov 16 '22 at 21:26
  • don't run with nonstopmode. At best run once on a command line simply with pdflatex yourfile so that you get a proper error message. – Ulrike Fischer Nov 16 '22 at 23:53

0 Answers0