# Can I disable \setminted for a code?

in order to apply a minted style globally and not to copy paste these styles in every \begin{minted} I will use in my paper, I am using

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{minted}
% global minted style
\setminted{
frame=lines,
framesep=2mm,
baselinestretch=1.2,
fontsize=\footnotesize,
linenos,
breaklines
}

\begin{document}

\begin{minted}{TypeScript}
code here
\end{minted}

\end{document}


so my question is if is it possible to disable these \setminted styles for some \begin{minted}?

• welcome to tex.sx. it will be easier for someone to help you if you expand your example to be compilable -- begin with \documentclass and end with \end{document}. – barbara beeton Jan 22 '18 at 0:42
• You can override options with the optional argument to \begin{minted}. But that might be a pain if you have many code blocks you want to override. Or you could use \setminted[lang]{...} if the different styles apply to different languages. Or you could use \newminted to create a new environment that does what you want. Would any of those options suit your use case? – David Purton Jan 22 '18 at 2:54
• I don't think using two \newcommand will work since the two \setminted commands will be cumulative. From my reading of the minted manual and source, I think using \newminted might work best. I'll post an answer and you can see what you think. – David Purton Jan 22 '18 at 14:04

Try using \newminted{TypeScript}{...} and then \begin{TypeScriptcode}.

\documentclass{article}
\usepackage{minted}
\newminted{TypeScript}{
frame=lines,
framesep=2mm,
baselinestretch=1.2,
fontsize=\footnotesize,
linenos,
breaklines
}
\begin{document}
\begin{TypeScriptcode}
code here
\end{TypeScriptcode}
\begin{minted}{TypeScript}
code here
\end{minted}
\end{document}


• Thank you, this should be the better practice to do it I think :) – GuesTeX Jan 22 '18 at 20:08