1

I ran into a problem of including a tex file via \inputminted from the minted package. When I try to add a frame around the code with frame=single I get lots of errors referring to missing $'s missing }'s and missing \item's.

The MWE is a self-referential tex-file with the following contents:

% this is: frames_for_minted_in_beamer.tex
\documentclass{beamer}

\usepackage{minted}

\begin{document}
\begin{frame}[fragile]
    \inputminted[%
        label=frames_for_minted_in_beamer.tex,%
        % frame=single,% this does not work
    ]{latex}{./frames_for_minted_in_beamer.tex}
\end{frame}
\end{document}

What went wrong here?

Ty for any help, Franz

1 Answer 1

1

The problem are the special characters you use in the label. Using the frame=single style will typeset the label at the top and unescaped math characters like _ will cause an error.

You can either escape them:

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}

% this is: frames_for_minted_in_beamer.tex
\documentclass{beamer}

\usepackage{minted}

\begin{document}
\begin{frame}[fragile]
    \inputminted[%
        label=frames\_for\_minted\_in\_beamer.tex,%
        frame=single,% this does not work
    ]{latex}{test.tex}
\end{frame}
\end{document}

or use the tcolorbox package to draw a simple frame without the label:

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}

\documentclass{beamer}

\usepackage[most]{tcolorbox}
\tcbuselibrary{minted}
\tcbset{listing engine=minted,colback=white,sharp corners}

\begin{document}
\begin{frame}[fragile=singleslide]
\tcbinputlisting{minted language=latex,listing file=test.tex,label=test}
\end{frame}
\end{document}
3
  • Any idea why it does not work the way I tried? I would prefer not to add another package and more code if possible.
    – Franz
    Oct 10, 2022 at 19:05
  • @Franz The underscores in your label cause the problem Oct 10, 2022 at 19:28
  • ty. works fine now.
    – Franz
    Oct 10, 2022 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .