0%

Latex宏包的增加

Latex增加mcode.sty宏包。

解决办法

本博客以mcode.sty宏包为例,如何在Latex增加该宏包。具体步骤如下:

**步骤1:**获取mcode.sty。在该MATLAB网站即可获取到该宏包。

**步骤2:**将该文件夹(mcode文件夹)放在目录下:C:\texlive\2022\texmf-dist\tex\latex\(或者%%%\texmf-dist\tex\latex\),此时mcode文件夹与其他宏包文件夹位于同一级目录。

**步骤3:**win+r 输入cmd,Ctrl+Shift+回车以管理员身份进入dos,然后输入texhash,以用于更新目录以便Latex发行版能找到新安装的宏包。

使用方法

1
2
3
4
5
6
7
8
9
\usepackage{listings}
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

\begin{lstlisting}
% Plot function f(x) = 2*x^3 - x - 2
ezplot('2*x^3-x-2',[0, 2])
hold on
plot([0,2],[0,0],'r')
\end{lstlisting}