나는 pdftex와 함께 라텍스를 사용하고 있으며 설명서 \mlttfamily
에 설명된 대로 Bera Mono 글꼴을 사용하려고 합니다 matlab-prettifier
. 그러나 생성된 출력 이음새가 내 \lstset
basicstyle = \mlttfamily
설정을 무시하고 대신 기본값을 사용합니까 \ttfamily
? 아래는 내 출력 이미지입니다.
\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}
답변1
이렇게 하면 문제가 해결되고 \lstset
기본 설정이 정의되며 \lstlisting
글꼴 변경 없이 이전에 이 스타일 설정을 덮어썼습니다.
다음 코드는 이제 글꼴을 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}
답변2
이제 matlab-prettier의 개요 설명에서 다음이 작동한다는 것을 알 수 있습니다.
\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}