我在编写的报告中将 MATLAB 脚本作为附录,使用 mcode 导入它,但有些行比我的纸张宽度还长。在我的主文档中,我有:
\usepackage[numbered]{mcode}
\usepackage[titletoc]{appendix}
body
\begin{appendices}
\appendix
\onecolumn
\small
\input{appendices.tex}
\end{appendices}
我的文档是两列,但在我包含的 appendices.tex 中有以下内容:
\newpage
\section{MATLAB FBA Script, quoted verbatim}
\lstinputlisting{MY_FILE_PATH.m}
\label{FBAscript}
不幸的是,我的代码中的某些行缺少结尾,特别是当我定义了长数组时。
您能否告诉我如何强制换行,同时保持正确的行号?
给我带来最大麻烦的部分是这些长长的 matlab 列表:
%biomassRxns = {'Biomass_BT_v2'};
%long including LTA/LPDC
%biomassRxns = {'EX_cpd00002(b)','EX_cpd00006(b)','EX_cpd00005(b)','EX_cpd00010(b)','EX_cpd00003(b)','EX_cpd00012(b)','EX_cpd00018(b)','EX_cpd00001(b)','EX_cpd00046(b)','EX_cpd00096(b)','EX_cpd00254(b)','EX_cpd00052(b)','EX_cpd00038(b)','EX_cpd00031(b)','EX_cpd11493(b)','EX_cpd00126(b)','EX_cpd10516(b)','EX_cpd00205(b)','EX_cpd11463(b)','EX_cpd15499(b)','EX_cpd00063(b)','EX_cpd11462(b)','EX_cpd11461(b)','EX_cpd15664(b)','EX_cpd00201(b)','LPDC_cpd15697(c)','LPDC_cpd15729(c)','LPDC_cpd15742(c)','LPDC_cpd15700(c)','LPDC_cpd15741(c)','LPDC_cpd15732(c)','LPDC_cpd15724(c)','LPDC_cpd15533(c)','LPDC_cpd15695(c)','LPDC_cpd15738(c)','LPDC_cpd15745(c)','LPDC_cpd15736(c)','LPDC_cpd15727(c)','LPDC_cpd15799(c)','LPDC_cpd15743(c)','LPDC_cpd15696(c)','LPDC_cpd15740(c)','LPDC_cpd15699(c)','LPDC_cpd15731(c)','LPDC_cpd15536(c)','LPDC_cpd15792(c)','LPDC_cpd15737(c)','LPDC_cpd15728(c)','LPDC_cpd15744(c)','LPDC_cpd15726(c)','LPDC_cpd15798(c)','LPDC_cpd15723(c)','LPDC_cpd15795(c)','LPDC_cpd15739(c)','LPDC_cpd15730(c)','LPDC_cpd15698(c)','LPDC_cpd15722(c)','LPDC_cpd15794(c)','LPDC_cpd15735(c)','LPDC_cpd15538(c)','LPDC_cpd15791(c)','LPDC_cpd15725(c)','LPDC_cpd15797(c)','LPDC_cpd15531(c)','LPDC_cpd15734(c)','LPDC_cpd15733(c)','LPDC_cpd15540(c)','LPDC_cpd15793(c)','LPDC_cpd15529(c)','LPDC_cpd15712(c)','LPDC_cpd15782(c)','LPDC_cpd15714(c)','LPDC_cpd15788(c)','LPDC_cpd15790(c)','LPDC_cpd15789(c)','LPDC_cpd15710(c)','LPDC_cpd15786(c)','LPDC_cpd15713(c)','LPDC_cpd15707(c)','LPDC_cpd15715(c)','LPDC_cpd15711(c)','LPDC_cpd15787(c)','LPDC_cpd15783(c)','LPDC_cpd15709(c)','LPDC_cpd15784(c)','LPDC_cpd15708(c)','LPDC_cpd15785(c)','LTA_cpd15747(c)','LTA_cpd15750(c)','LTA_cpd15753(c)','LTA_cpd15749(c)','LTA_cpd15754(c)','LTA_cpd15752(c)','LTA_cpd15748(c)','LTA_cpd15751(c)','LTA_cpd15746(c)','LTA_cpd15759(c)','LTA_cpd15775(c)','LTA_cpd15767(c)','LTA_cpd15768(c)','LTA_cpd15766(c)','LTA_cpd15758(c)','LTA_cpd15757(c)','LTA_cpd15777(c)','LTA_cpd15776(c)','LTA_cpd15769(c)','LTA_cpd15761(c)','LTA_cpd15762(c)','LTA_cpd15756(c)','LTA_cpd15755(c)','LTA_cpd15764(c)','LTA_cpd15771(c)','LTA_cpd15760(c)','LTA_cpd15779(c)','LTA_cpd15774(c)','LTA_cpd15781(c)','LTA_cpd15763(c)','LTA_cpd15772(c)','LTA_cpd15770(c)','LTA_cpd15765(c)','LTA_cpd15773(c)','LTA_cpd15780(c)','LTA_cpd15778(c)'};
%long reaction list
%biomassRxns = {'EX_cpd00002(b)','EX_cpd00006(b)','EX_cpd00005(b)','EX_cpd00010(b)','EX_cpd00003(b)','EX_cpd00012(b)','EX_cpd00018(b)','EX_cpd00001(b)','EX_cpd00046(b)','EX_cpd00096(b)','EX_cpd00254(b)','EX_cpd00052(b)','EX_cpd00038(b)','EX_cpd00031(b)','EX_cpd11493(b)','EX_cpd00126(b)','EX_cpd10516(b)','EX_cpd00205(b)','EX_cpd11463(b)','EX_cpd15499(b)','EX_cpd00063(b)','EX_cpd11462(b)','EX_cpd11461(b)','EX_cpd15664(b)','EX_cpd00201(b)','EX_cpd15800(b)','EX_cpd15670(b)'};
%long less teichoic acid composition
biomassRxns = {'EX_cpd00002(b)','EX_cpd00006(b)','EX_cpd00005(b)','EX_cpd00010(b)','EX_cpd00003(b)','EX_cpd00012(b)','EX_cpd00018(b)','EX_cpd00001(b)','EX_cpd00046(b)','EX_cpd00096(b)','EX_cpd00254(b)','EX_cpd00052(b)','EX_cpd00038(b)','EX_cpd00031(b)','EX_cpd11493(b)','EX_cpd00126(b)','EX_cpd10516(b)','EX_cpd00205(b)','EX_cpd11463(b)','EX_cpd15499(b)','EX_cpd00063(b)','EX_cpd11462(b)','EX_cpd11461(b)','EX_cpd15664(b)','EX_cpd00201(b)','EX_cpd15800(b)'};
%biomassRxns = {'rxnBSbiomass'};
%biomassRxns = {'rxnBSbiomass_f_2'}
答案1
\usepackage[numbered,breaklines=true]{mcode}
正确地分割长数组,这就是我正在寻找的解决方案。