This question already has an answer here:

I have set a new matcode environment in order to have some matlab code in my .tex file, using the matlab-prettifier package (combined with the listings package). However, I have a problem with the tilde symbol.



% Avoid the spurious error
% apply the fix


    \fontfamily{cmr} \fontsize{8}{10}\selectfont
                basicstyle = \ttfamily,

    % This is a comment.
    [~, a ] 


If I use the kerkis.sty package, then the result is going to be this one, where I miss the tilde symbol (apparently the tilde symbol is not supported by kerkis): enter image description here

Ignoring (by commenting) the kerkis.sty package, the result is going to be this one: enter image description here

Although the tilde symbol is somewhat displaced, at least it is visible. As you can see, I tried to load the cmr font inside the matcode environment, but I had no luck with that. So my question is:

How can I load the cmr font inside my matcode environment, without commenting the command \usepackage{kerkis}?

Edit: In order to override this problem and make the tilde symbol appear, I used the escapechar # and I replaced the tilde symbol in my .tex file, with the command #\texttildelow#, but this is not a neat solution for sure.

marked as duplicate by jub0bs, Werner, Svend Tveskæg, egreg environments Aug 27 '15 at 19:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.