0

I want to use minted to display code in Latex in a customized font, e.g. Monaco. Here is my code.

\documentclass{article}
\usepackage{fontspec}
\usepackage{minted}
\newfontfamily\monaco{Monaco}
\setminted[matlab]{fontfamily=\monaco}
\begin{document}
  \begin{minted}{matlab}
    clear all;
    syms k t f har;
    left = -10; right = 10; down = -0.5; up = 1.5;
    f = sinc(k/2)/2 * exp(1j*k*pi*t/2)
  \end{minted}
\end{document}

However, when I build the code in vscode, the intepreter get stuck and takes 90% of the CPU. Meanwhile, it gives me the following error.

Missing \endcsname inserted.

If I do not use \newfontfamily command then I can only use the pre-defined fontfamily. How can I use a customized font in minted?

  • 1
    Do you only want to use that font for Matlab code or all monospaced text in the document (then \setmonofont would be easiest). If only for that, you should try using the NFSS name. – TeXnician Nov 9 '19 at 13:04
0

fontfamily should not be a command calling a font but a nfss-family name. You can declare such a familyname with the NFSSFamily key (I used Arial as I don't have your font):

\documentclass{article}
\usepackage{fontspec}
\usepackage{minted}
\newfontfamily\monaco{Arial}[NFSSFamily=ArialFamily]
\setminted[matlab]{fontfamily=ArialFamily}
\begin{document}
  \begin{minted}{matlab}
    clear all;
    syms k t f har;
    left = -10; right = 10; down = -0.5; up = 1.5;
    f = sinc(k/2)/2 * exp(1j*k*pi*t/2)
  \end{minted}
\end{document}
|improve this answer|||||

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.