I have an appendix with a full Matlab script, quoted verbatim, numbered and coloured as I want.
However, I want to quote about 10 lines of it as a figure in the body of my report, and since I will not quote any specific line numbers, they do not need to be included (the numbers also look nasty next to a table with a wrapped caption, where you get the 1 essentially sitting on the hyphen!)
At the moment, I have numbered turned on in the package options, and cannot seem to turn it off for the extract.
Alternatively, I could take the numbered out of the package options and then tell it to number the appendix.
\documentclass{article}
\usepackage[numbered,breaklines=true]{mcode}
\begin{document}
some body
\begin{figure}[h]
\begin{lstlisting}[language=Matlab,breaklines=true]
% loop over different monosaccharide in minimal media
offset = 2;
for j = 1:length(carbonSourceList)
disp(['Current carbon source in media is: ', carbonSourceList{j}]);
%fprintf('\n');
lbColumn = (j - 1) * offset + 2;
%ubColumn = (j - 1) * offset + 3;
ubColumn = lbColumn + 1;
currentFBAsettings = allFBAsettings(:, [1 lbColumn:ubColumn]);
tempModel = batch_modify_flux_bounds(currentFBAsettings, origModel);
\end{lstlisting}
\label{Extract}
\caption{Extract from FBA Matlab script showing looping over different carbon sources}
\end{figure}
more body
\newpage
\appendix
\onecolumn
\small
\newpage
\section{MATLAB FBA Script, quoted verbatim}
%\lstinputlisting[language=Matlab,breaklines=true]{ATCC29149_FBA_all_v4_3.m}
\begin{lstlisting}[language=Matlab,breaklines=true]
% loop over different monosaccharide in minimal media
offset = 2;
for j = 1:length(carbonSourceList)
disp(['Current carbon source in media is: ', carbonSourceList{j}]);
%fprintf('\n');
lbColumn = (j - 1) * offset + 2;
%ubColumn = (j - 1) * offset + 3;
ubColumn = lbColumn + 1;
currentFBAsettings = allFBAsettings(:, [1 lbColumn:ubColumn]);
tempModel = batch_modify_flux_bounds(currentFBAsettings, origModel);
\end{lstlisting}
\label{FBAscript}
\end{document}
This produces both with numbers. When I tried putting numbered=False as a parameter, it started throwing up error messages about breaklines, which works when a 'numbered' parameter is not included in the \lstinputlisting options.
matlab-prettifierpackage; it improves uponmcodein many ways. See this answer, for instance. – jub0bs Sep 07 '14 at 13:14