
我正在尝试在论文中添加包含 Matlab 脚本的附录。我曾使用邮报在这里。
在我的 main.tex 中我添加了:
\usepackage[T1]{fontenc}
\usepackage{bigfoot} % to allow verbatim in footnote
\usepackage[numbered,framed]{matlab-prettifier}
....
\part*{Appendices}
\chapter{Matlab scripts}
\input{matlab_scripts.tex}
\end{document}
然后在 matlab_scripts.tex (附录文件)中:
\section{Realisation the algorithm 1}
\begin{filecontents*}{ algorithm.m}
function [a,b] = algorithm(c,d)
% matlab script of the function
\end{filecontents*}
\let\ph\mlplaceholder % shorter macro
\lstMakeShortInline"
\lstset{
style = Matlab-editor,
basicstyle = \mlttfamily,
escapechar = ",
mlshowsectionrules = true,
}
\lstlistoflistings
\lstinputlisting{algorithm.m}
我正在使用 TexStudio,但它无法生成 pdf 文件,并且会给出错误。如果没有此附录,它就可以正常工作。我哪里做错了?
编辑1:
我已修复以下错误:
\section{Realisation the algorithm 1}
\begin{filecontents*}{ algorithm.m}
function [a,b] = algorithm(c,d)
% matlab script of the function
\end{filecontents*}
\lstinputlisting{algorithm.m}