# numbering isn't showing with matlab-pretifier package

does anybody know why this might be? I tried changing my document class from "Article" to "Beamer" and also tried deleting a bunch of packages but nothing has made the numbering on the Matlab-editor style appear. I copy-pasted the example from the documentation, but everything except the numbering appears. Does anybody know why this might be? Thank you

Example (revised, streamlined attempt):

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{matlab-prettifier}

\begin{document}
\maketitle
\section*{Problem 1}
We verify the $LU$ decomposition of $T$ by following the $LU$ decomposition algorithm used from Homework 2, onward. This process is iterative, so it is helpful to identify the elements of $L$ by the stage of their iteration.

The algorithm goes like this:\\
\begin{lstlisting}[
style=Matlab-editor,
basicstyle=\mlttfamily,
escapechar=,
]
function [L,U] = GE(A)
%The square matrix A has LU decomposition
[n,n] = size(A);
for k = 1:n-1

A(k+1:n,k) = A(k+1:n,k)/A(k,k)
%each element underneath the k'th diagonal element is
%divided by said element.
A(k+1:n,k+1:n) = A(k+1:n,k+1:n) - A(k+1:n,k)*A(k,k+1:n)
%The elements of the lower-right submatrix of dimension
%(n-k-1)x(n-k-1) are updated. See figures in the
%explanation below.
end
L = eye(n,n) + tril(A,-1);
U = triu(A);
\end{lstlisting}

\end{document}

• Hi, welcome. Can you show us some example code demonstrating the problem, i.e. a minimal working example? Commented Feb 27, 2018 at 8:58
• Yes, thank you, I have added a picture of my situation. matlab-pretifier is used on line 45 within the lstlisting command. I simply copy-pasted the example I wanted to imitate from the documentation, which had numbering, but when I pasted it, the numbering wasn't there. Afterwards, I put my own MATLAB code in place of the example MATLAB code. Commented Feb 27, 2018 at 9:09
• Code as picture is just hopeless. Paste the code in, select it and click the button marked {} (or hit Ctrl + K). Also, please show the configuration of the package from the preamble. Commented Feb 27, 2018 at 9:09
• fixed, thanks, code is shown. packages listed first, then the part where I copy-pasted the pretifier example, but put my own MATLAB code in place of theirs Commented Feb 27, 2018 at 9:15
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. Commented Mar 13, 2018 at 13:48

Seems you need

\usepackage[numbered]{matlab-prettifier}


to turn on numbering, it's not enabled by default. (You could also have added numbers=left to the lstlisting options). You also want

\usepackage[T1]{fontenc}


to get the correct font, as mentioned in the manual of matlab-prettifier:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % you need this to get the fonts right
\usepackage[english]{babel}

\begin{document}
The algorithm goes like this:
\begin{lstlisting}[
style=Matlab-editor,
basicstyle=\mlttfamily,
escapechar=,
]
function [L,U] = GE(A)
%The square matrix A has LU decomposition
[n,n] = size(A);
for k = 1:n-1

A(k+1:n,k) = A(k+1:n,k)/A(k,k)
%each element underneath the k'th diagonal element is
%divided by said element.
A(k+1:n,k+1:n) = A(k+1:n,k+1:n) - A(k+1:n,k)*A(k,k+1:n)
%The elements of the lower-right submatrix of dimension
%(n-k-1)x(n-k-1) are updated. See figures in the
%explanation below.
end
L = eye(n,n) + tril(A,-1);
U = triu(A);
\end{lstlisting}
\end{document}

• Thanks, man, this fixed everything AND improved my formatting. It is the best answer. Thank you so much! Commented Feb 27, 2018 at 9:30