[Tex/LaTex] LaTeX packages minted and scrhack

errorskoma-scriptminted

I'd like to use the minted package and the scrhack package in the same LaTeX document, that is:

\usepackage{scrhack}
\usepackage{minted}

However, I get the following error:

/usr/local/texlive/2013/texmf-dist/tex/latex/minted/minted.sty:215: Package scrhack Error: extension `lol' already in use. [...t{listing}{h}{lol}[\minted@float@within]}]

Edit:
The problem was that I used the package classicthesis and included both, listing and minted. I cannot completely replicate the error, but this MWE has a very similar error message:

\documentclass{scrreprt}

\usepackage{scrhack}
\usepackage{minted}
\usepackage{listings}



\begin{document}

    Hello, World!

\end{document}

The error message is:

There were errors in your LaTeX source

/usr/local/texlive/2013/texmf-dist/tex/latex/koma-script/listings.hak:136: Package tocbasic Error: file extension `lol' cannot be used twice . [}]

Now, I removed listings (and all related parts) in the classicthesis-config.tex file and everything works fine. I don't think, that I'll need both packages, so my problem is solved.

Best Answer

The package scrhack redefines macros of other packages. It should be loaded at the very end. Luckily the following then already compiles without errors:

\documentclass{scrreprt}

\usepackage{listings}
\usepackage{minted}
\usepackage{scrhack}

\begin{document}
    Hello, World!
\end{document}

If you really need to include scrhack somewhere else, you could use the \AtEndPreamble hook provided by the etoolbox package.