1

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
  • 1
    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
  • @DavidPurton With \setminted[lang]{...} it would be different styles for different languages tho, so it's the same problem for that specific lang's style later. For changing between styles I have to use \newcommand{\mintedstyleone}{\setminted{...}} and another \newcommand{\mintedstyletwo}{\setminted{...}} I guess.. – GuesTeX Jan 22 '18 at 13:44
  • 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
1

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.