I am writing my thesis and got stuck up with this problem.

I am using Times New Roman as default font by loading

\setmainfont{Times New Roman}

and I compile the TEX file using XeLaTeX. In the appendix I need to put my MATLAB code. I have used \usepackage{mcode}.

When I run the file using XeLaTeX the fonts in my MATLAB code go to Times New Roman. But, I need the MATLAB code to be in default MATLAB font. How should I locally change the font?


First of all that shouldn't be the case. By default mcode uses the font Courier. See line 178-179 in mcode.sty:

% default font

So what you want do to is redefine \lstbasicfont. As far as I remember MATLAB uses Helvetica as default font. So just add


after loading mcode.

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.