Verwendung der Schriftart Bera Mono mit \mlttfamily, beschrieben durch matlab-prettifier

Verwendung der Schriftart Bera Mono mit \mlttfamily, beschrieben durch matlab-prettifier

Ich verwende Latex mit PDFTex und versuche, die Schriftart Bera Mono wie \mlttfamilyin der Dokumentation beschrieben zu verwenden matlab-prettifier. Meine generierte Ausgabe scheint meine \lstset basicstyle = \mlttfamilyEinstellung jedoch zu ignorieren und verwendet \ttfamilystattdessen die Standardeinstellung. Unten sehen Sie ein Bild meiner Ausgabe.

\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}

Ausgabebild

Antwort1

Dies behebt das Problem, \lstsetdefiniert die Standardeinstellung \lstlistingund ich habe diese Stileinstellung zuvor überschrieben, ohne die Schriftart zu ändern.
Der folgende Code ändert die Schriftart jetzt korrekt in 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}

Antwort2

Aus der Übersichtsbeschreibung von matlab-prettier erkenne ich nun, dass folgendes funktioniert.

            \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}

Ausgabe

verwandte Informationen