How can I tell LaTeX to number the code the way I tried above? Thanks in advance!
Some nitpicking:
You can't "tell" LaTeX to number (in whatsoever ways) the code because LaTeX must not modify (in whatsoever ways) the .tex-source code of a document while "numbering code" can be subsumed under "modifying code".
But you can "tell" LaTeX to number in the way you exhibited above some items of sectioning that may be represented by portions of .tex-source-code and that appear when viewing/displaying/printing the .pdf-file which comes into being as one of the results of compiling the .tex-source-code. ;-)
With most document classes for LaTeX you have sectioning commands like \chapter
, \section
, etc.
With most document classes for LaTeX for each of these sectioning commands a so-called "starred" variant exists which does produce the item of sectioning without a sectioning number (and without an entry in the table of contents, and without a bookmark in case of using hyperref, and without changing the page headings).
\documentclass{report}
\usepackage{hyperref}
\newtheorem{Definition}{Def}[chapter]
\newtheorem{Proposition}[Definition]{Proposition}
\begin{document}
\tableofcontents
\chapter{Chapter}
\section*{Section A}\addcontentsline{toc}{section}{Section A}
\begin{Definition}...\end{Definition}
\begin{Definition}...\end{Definition}
\begin{Definition}...\end{Definition}
\begin{Definition}...\end{Definition}
\begin{Proposition}...\end{Proposition}
\section*{Section B}
\begin{Definition}...\end{Definition}
\end{document}
Page 1:

Page 2:

\renewcommand{\thesection}{}
?