Uso da fonte Bera Mono com \mlttfamily descrito por matlab-prettifier

Uso da fonte Bera Mono com \mlttfamily descrito por matlab-prettifier

Estou usando latex com pdftex e tentando usar a fonte Bera Mono com o \mlttfamilydescrito na matlab-prettifierdocumentação. No entanto, minha saída gerada parece ignorar minha \lstset basicstyle = \mlttfamilyconfiguração e usa o padrão \ttfamily? Abaixo está a imagem da minha saída.

\documentclass[border=30pt]{standalone} 

\usepackage[final]{matlab-prettifier}

\usepackage[T1]{fontenc}

\lstset{
  style              = Matlab-editor,
  basicstyle         = \mlttfamily, %\ttfamily
  escapechar         = ",
  mlshowsectionrules = true,
}

\begin{document}

\begin{lstlisting}[style=Matlab-editor]
%% Code sections are highlighted.
% System command are supported...
!gzip sample.m
% ... as is line continuation.
A = [1, 2, 3,... % (mimicking the ouput is good)
 4, 5, 6]
fid = fopen('testFile.text', 'w')
for i=1:10
  fprintf(fid,'%6.2f \n', i);
end
x=1; %% this is just a comment, though
% Context-sensitive keywords get highlighted correctly...
p = properties(mydate); %(here, properties is a function)
x = linspace(0,1,101);
y = x(end:-1:1)
% ... even in nonsensical code.
]end()()(((end end)end ))))end (function end
%{
    block comments are supported
%} even
runaway block comments
are
   \end{lstlisting}

\end{document}

imagem de saída

Responder1

Isso corrige o problema, \lstsetdefine a configuração padrão \lstlistinge eu estava substituindo essa configuração de estilo anteriormente sem alterar a fonte.
O código a seguir agora altera corretamente a fonte para Bera Mono.

\documentclass[border=30pt]{standalone} 

\usepackage[final]{matlab-prettifier}

\usepackage[T1]{fontenc}

\lstset{
  style              = Matlab-editor,
  basicstyle         = \mlttfamily, %\ttfamily
  escapechar         = ",
  mlshowsectionrules = true,
}

\begin{document}

\begin{lstlisting}
%% Code sections are highlighted.
% System command are supported...
!gzip sample.m
% ... as is line continuation.
A = [1, 2, 3,... % (mimicking the ouput is good)
     4, 5, 6]
fid = fopen('testFile.text', 'w')
for i=1:10
  fprintf(fid,'%6.2f \n', i);
end
x=1; %% this is just a comment, though
% Context-sensitive keywords get highlighted correctly...
p = properties(mydate); %(here, properties is a function)
x = linspace(0,1,101);
y = x(end:-1:1)
% ... even in nonsensical code.
]end()()(((end end)end ))))end (function end
%{
    block comments are supported
%} even
runaway block comments
are
\end{lstlisting}

\end{document}

Responder2

Vejo agora pela descrição geral do matlab-prettier que o seguinte funciona.

            \documentclass[border=30pt]{standalone} 

            \usepackage[final]{matlab-prettifier}

            \usepackage[T1]{fontenc}

            \begin{document}

            \begin{lstlisting}[
              style      = Matlab-editor,
              basicstyle = \mlttfamily,
            ]

            %% Code sections are highlighted.
            % System command are supported...
            !gzip sample.m
            % ... as is line continuation.
            A = [1, 2, 3,... % (mimicking the ouput is good)
                 4, 5, 6]
            fid = fopen('testFile.text', 'w')
            for i=1:10
              fprintf(fid,'%6.2f \n', i);
            end
            x=1; %% this is just a comment, though
            % Context-sensitive keywords get highlighted correctly...
            p = properties(mydate); %(here, properties is a function)
            x = linspace(0,1,101);
            y = x(end:-1:1)
            % ... even in nonsensical code.
            ]end()()(((end end)end ))))end (function end
            %{
                block comments are supported
            %} even
            runaway block comments
            are

            \end{lstlisting}

            \end{document}

Saída

informação relacionada