First, your sections are numbered \thechapter.\arabic{section} , so I assume that the numbering \thesection.<listing> will be more like 1.1.1 , 1.1.2 , ...
When using minted , the game counter is not lstlisting , but rather listing . So you need
\makeatletter \renewcommand*{\thelisting}{\thesection.\arabic{listing}} \@addtoreset{listing}{section} \makeatother
in the preamble. The last \@addtoreset resets the listing counter with each new \section . You can also do this in one step if you use the chngcntr package:
\usepackage{chngcntr}% http:
\counterwithin performs both of the above operations (view \thelisting as well as reset).

\documentclass{report} % Imports %\usepackage{listings} \usepackage{minted,xcolor,chngcntr} % Style Minted \usemintedstyle{default} \definecolor{codebg}{rgb}{0.96,0.96,0.96} \newminted{python}{bgcolor=codebg, linenos=true, frame=lines, numbersep=5pt, fontsize=\footnotesize} \renewcommand\listoflistingscaption{LIST OF CODE SNIPPETS} \renewcommand\listingscaption{Code Snippet} % Style Listings \counterwithin{listing}{section} \begin{document} \listoflistings \chapter{A Chapter} \section{A Section} \subsection{A Sub-Section} Nam pulvinar euismod facilisis. Quisque vel sagittis diam. In ut egestas sem. Cras sit amet purus elementum, tempor nisi at, imperdiet diam. Mauris rhoncus vitae erat vel laoreet. Suspendisse interdum aliquet bibendum. Quisque venenatis leo eget neque blandit ullamcorper. \begin{listing}[H] \begin{pythoncode} def get_path_leaf(path): """ return the leaf of a path. """ if not isinstance(path, str): path = str(path) head, tail = ntpath.split(path) return tail or ntpath.basename(head) \end{pythoncode} \caption{SPARQL Endpoint} %\label{lst:SPARQL Endpoint} \end{listing} Aenean pharetra at mauris at posuere. Vivamus ante libero, posuere et luctus in, condimentum in lacus. Nam rhoncus mi nunc, consequat rhoncus sapien lobortis eu. Fusce feugiat orci nec sollicitudin cursus. Nunc at ligula mi. Vestibulum nec pharetra lacus. Suspendisse a ultrices massa. Nulla mauris purus, tempus quis convallis id, pellentesque vel nibh. \begin{listing}[H] \begin{pythoncode} def get_path_leaf(path): """ return the leaf of a path. """ if not isinstance(path, str): path = str(path) head, tail = ntpath.split(path) return tail or ntpath.basename(head) \end{pythoncode} \caption{SPARQL Endpoint} %\label{lst:SPARQL Endpoint} \end{listing} \section{Another section} Aenean pharetra at mauris at posuere. Vivamus ante libero, posuere et luctus in, condimentum in lacus. Nam rhoncus mi nunc, consequat rhoncus sapien lobortis eu. Fusce feugiat orci nec sollicitudin cursus. Nunc at ligula mi. Vestibulum nec pharetra lacus. Suspendisse a ultrices massa. Nulla mauris purus, tempus quis convallis id, pellentesque vel nibh. \begin{listing}[H] \begin{pythoncode} def get_path_leaf(path): """ return the leaf of a path. """ if not isinstance(path, str): path = str(path) head, tail = ntpath.split(path) return tail or ntpath.basename(head) \end{pythoncode} \caption{SPARQL Endpoint} %\label{lst:SPARQL Endpoint} \end{listing} \end{document}
You will notice that I used the report document class, since I don't have thesis . However, I suppose that would be like some degree.