我有两种方法可以将 Matlab 代码插入 Latex。但它们都有一个缺点,我想改变它。首先,我展示我的代码和结果:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{a4paper,left=3cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
\usepackage{sectsty}
\sectionfont{\fontsize{14}{14}\selectfont}
\subsectionfont{\fontsize{12}{12}\selectfont}
\usepackage{setspace}
\renewcommand{\baselinestretch}{1.5}
\usepackage{minted}
\usepackage{listings} %code extracts
\usepackage{xcolor} %custom colours
\usepackage{mdframed} %nice frames
\definecolor{light-gray}{gray}{0.95} %the shade of grey that stack exchange uses
\begin{document}
\noindent \textbf{Example using minted package}:
\definecolor{bg}{rgb}{0.95,0.95,0.95}
\begin{minted}[bgcolor=bg]{matlab}
A = [1 0; 2 4];
B = [5 9; 2 1];
if isequal(size(A),size(B))
C = A + B;
end
C
>>
C =
6 9
4 5
\end{minted}
\noindent \textbf{Example using mdframed package}:
\begin{mdframed}[backgroundcolor=light-gray, roundcorner=10pt,leftmargin=1, rightmargin=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15, outerlinewidth=1, linecolor=light-gray]
\begin{lstlisting}[language = matlab]
A = [1 0; 2 4];
B = [5 9; 2 1];
if isequal(size(A),size(B))
C = A + B;
end
C
>>
C =
6 9
4 5
\end{lstlisting}
\end{mdframed}
\end{document}
我想知道如何将 eg.1 的字体改为 eg.2,因为 eg.2 的字体更美观。或者如何将 eg.2 中的关键字颜色从黑色改为彩色?
我不知道该如何修复它们。请帮帮我。提前谢谢!