[Tex/LaTex] Change start number on\lstinputlisting

line-numberinglistingsnumbering

I am attempting to change the starting number of some Matlab code from 1 to 236. I tried using firstline=236 but nothing was output after compilation.

Can you assist me in getting the code numbering to start from 236?

Here is what I have thus far:

\documentclass{book}

\usepackage{listings}
\usepackage{xcolor}
\usepackage[numbered,framed]{matlab-prettifier}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.m}
 % detect if next step is an obstacle
                if bug.isoccupied(robot + [dx; dy])
                    bug.message('(%d,%d) obstacle!', n);
                    bug.H(bug.j,:) = robot; % define hit point
                    bug.step = 2;
                    % get a list of all the points around the obstacle
                    bug.edge = edgelist(bug.occgridnav == 0, robot);
                    %bug.k = 2;  % skip the first edge point, we are already there
                    bug.k = size(bug.edge,2)
                else
                    n = robot + [dx; dy];
                end
            end % step 1
\end{filecontents*}


\lstdefinestyle{mystyle}{
numbers=left,
numberstyle=\small,
numbersep=8pt,
%language=Matlab,
style=Matlab-editor,
basicstyle=\ttfamily\small,
numbersep=22pt,
frame=none
}


\begin{document}


\lstinputlisting[%firstline = 236,
backgroundcolor=\color{blue!10},
style=Matlab-editor,
basicstyle=\mlttfamily\scriptsize,
caption={[First Change to the Bug2 Algorithm]{First Change to the Bug2 Algorithm}},
label = mat:line246]{\jobname.m}

\end{document} 

Best Answer

The correct option is firstnumber=236!

See the following code:

\documentclass{book}

\usepackage{listings}
\usepackage{xcolor}
\usepackage[numbered,framed]{matlab-prettifier}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.m}
 % detect if next step is an obstacle
                if bug.isoccupied(robot + [dx; dy])
                    bug.message('(%d,%d) obstacle!', n);
                    bug.H(bug.j,:) = robot; % define hit point
                    bug.step = 2;
                    % get a list of all the points around the obstacle
                    bug.edge = edgelist(bug.occgridnav == 0, robot);
                    %bug.k = 2;  % skip the first edge point, we are already there
                    bug.k = size(bug.edge,2)
                else
                    n = robot + [dx; dy];
                end
            end % step 1
\end{filecontents*}


\lstdefinestyle{mystyle}{
numbers=left,
numberstyle=\small,
numbersep=8pt,
%language=Matlab,
style=Matlab-editor,
basicstyle=\ttfamily\small,
numbersep=22pt,
frame=none
}


\begin{document}


\lstinputlisting[%
  %firstline = 236,
  firstnumber=236, % <==================================================
  backgroundcolor=\color{blue!10},
  style=Matlab-editor,
  basicstyle=\mlttfamily\scriptsize,
  caption={[First Change to the Bug2 Algorithm]{First Change to the Bug2 Algorithm}},
  label = mat:line246
]{\jobname.m}

\end{document}

and the result:

enter image description here