Have “enumerate” continue the numbering of Sections, Subsections, Subsubsections, etc

I'm using MikTex and I'm attempting to create a government statute-type document that has nested levels such as:

I. Section
A. Subsection
1. Subsubsection


etc.

Additionally, I would like "enumerate" to start where the section, subsection, etc. leaves off, such that \begin{enumerate} starts with A. or B. underneath a section, or 1. or 2. underneath a subsection, etc., such that rather than having the section title, it prints normal text as needed.

I have been attempting to use the following code to change the section numbering (based on other answers on stackexchange), but I continue to get an error reading "Undefined control sequence. \subsection{name of subsection}".

\renewcommand\thesection{\Roman{Section}}
\renewcommand\thesubsection{\Alpha{Subsection}}
\renewcommand\thesubsubsection{\arabic{Subsubsection}}


I know I could manually reset the numbering using something like the following:

\begin{enumerate}
\setcounter{enumi}{3}
\item Continue numbering
\end{enumerate}


However, I'm hoping to automate the process. I hope this makes sense as to what I'm attempting to accomplish. Please let me know if I can clarify further.

Here's a minimum working example.

\documentclass[a4paper,12pt]{article}
\usepackage{color}
\usepackage{graphicx}
\usepackage{float}
\usepackage{lipsum}
\usepackage{natbib}
\usepackage{setspace, graphicx, fullpage, fancyhdr, amssymb, amsmath, epsfig, array, multirow, hyperref, tabularx, lscape, booktabs, sidecap, subfig, longtable, enumitem, libertine, todonotes}
\usepackage{caption}
\usepackage[hang]{footmisc}
\usepackage{multicol}
\renewcommand\thesection{\Roman{Section}}
\renewcommand\thesubsection{\Alpha{Subsection}}
\renewcommand\thesubsubsection{\arabic{Subsubsection}}

\begin{document}

\pagenumbering{arabic}
\title{\huge The Constitution}
\author{\large The Author}
\date{\today}
\maketitle

\tableofcontents

\newpage

\section{Preamble}

\subsection{Name}

We shall be called The Government.

\subsection{Purpose}
\begin{enumerate}
\item To represent the people.
\item To preserve democracy.
\end{enumerate}
\subsection{Senate}
Who are the members?
\subsubsection{Voting Members}
These people can vote.
\end{document}


TL;DR I need \renewcommand\thesection{\Roman{Section}} to work, and I need the enumerate function to continue the numbering of the section wherever it leaves off to print normal text rather than titles.

EDIT: A visual example from a legislative drafting website (but with a different numbering order/layout):

(a) (Subsection could be a label/heading, but also could be just the enumerate at the same level as plain text)

(1) (Subsubsection, could be a label/heading, but also could be just the enumerate at the same level as plain text)

(A) (Paragraph, should be text)

(i) (Clause, should be text)

(I) (Subclause, should be text)


EDIT 2:

• for the first issue, it should be \Roman{section}, \Alph{subsection} and \arabic{subsubsection}. Should the "to represent the people" enumerate label be B.1 or I.B.1? – Troy Dec 25 '18 at 19:01
• @Troy thanks for your answer! The label should actually be just the number, aka 1. – ryuhekai Dec 25 '18 at 19:39
• oh? then I'm afraid I don't understand your question anymore. what does "I need the enumerate function to continue the numbering of the section" mean then? – Troy Dec 25 '18 at 19:41
• I tried to use the {section} change and still got the same error...I'm still struggling to figure out what's wrong there. – ryuhekai Dec 25 '18 at 19:55
• delete your auxiliary (aux, toc etc.) files and recompile. your exact MWE with my suggested changes works here. – Troy Dec 25 '18 at 19:57

If you also want text within sections indented as if these were items of an enumeration environment, you may want to consider also using replacing the sectioning commands by enumerations.

I'm setting up an enumeration environment called ryuenum below that allows you to use \Item{<title>} instead of \item to produce items with a heading that is formatted like a section heading of the appropriate depth. It also inserts an entry in the TOC.

\documentclass{article}

\usepackage{enumitem}
\newlist{ryuenum}{enumerate}{5}                             %% <- max depth = 5
\setlist[ryuenum]{align=left,labelindent=0pt,               %% <- label placement
listparindent=\parindent,parsep=\parskip} %% <- set parindent/parskip

\setlist[ryuenum,1]{label=\Roman*.,ref=\Roman*,
before={\ryuenumsetup[\ryutoctop]{section}{.5em}{.5em}{\Large\bfseries}}}
\setlist[ryuenum,2]{label=\Alph*.,ref=\Alph*,
before={\ryuenumsetup{subsection}{.5em}{.5em}{\large\bfseries}}}
\setlist[ryuenum,3]{label=\arabic*.,ref=\arabic*,
before={\ryuenumsetup{subsubsection}{.5em}{.5em}{\normalsize\bfseries}}}
\setlist[ryuenum,4]{label=\roman*.,ref=\roman*}
\setlist[ryuenum,5]{label=\alph*.,ref=\alph*}

%% Sets parameters that determine appearance of headings/toc entries:
\newlength\ryuspacebefore \newlength\ryuspaceafter
\newcommand\ryuenumsetup[5][\ryutocnormal]{%
\let\ryutocformat#1%
\def\ryusecdp{#2}%
\setlength{\ryuspacebefore}{#3}%
\setlength{\ryuspaceafter}{#4}%
\def\ryusecformat{#5}%
}

%% Toc entry styles:
\newcommand*\ryutocnormal[2]{\protect\numberline{#1.}#2}
\newcommand*\ryutoctop[2]{Article #1: #2}

%% The \Item command
\makeatletter %% <- make @ usable in command sequences
\newcommand*\Item[1]{%
\begingroup                                  %% <- limit scope of font change
\normalfont\ryusecformat                   %% <- set font
\par\vspace{\ryuspacebefore}%              %% <- space above
\item                                      %% <- item
\interlinepenalty\@M                       %% <- inhibit page breaks
#1\par%                                    %% <- heading, paragraph break
\vspace{\ryuspaceafter}                    %% <- space below
\csname\ryusecdp mark\endcsname{#1}%       %% <- \sectionmark etc.
\ifx\ryusecdp\empty\else                   %% <- if ryusecdp is non-empty
\addcontentsline{toc}{\ryusecdp}         %% <- ...create toc entry at right depth
{\ryutocformat{\@currentlabel}{#1}}%   %% <- ... with the right number/name
\fi
\endgroup
\@afterheading                               %% <- prohibit indentation and enum topsep
\ignorespaces                                %% <- does what it says
}
\makeatother  %% <- revert @

\usepackage{hyperref} %% <- not necessary, but compatible

\begin{document}

\tableofcontents

\vspace{1cm}\noindent\rule{\linewidth}{1pt}\par\vspace{1cm}

\begin{ryuenum}
\Item{Preamble}
\begin{ryuenum}
\Item{Name}
We shall be called The Government.
\Item{Purpose}
\begin{ryuenum}
\item To represent the people.
\begin{ryuenum}
\item subclause!
\end{ryuenum}
\item To preserve democracy.
\end{ryuenum}
\Item{Senate}
Who are the members?
\begin{ryuenum}
\Item{Voting Members}
These people can vote.
\end{ryuenum}
\end{ryuenum}
\Item{Final item}
Lorem ipsum dolor sit.
\end{ryuenum}

\end{document}


I'm using the enumitem package (which I see you're also using) to set up a custom list environment and I'm setting this environment up with

before={\ryuenumsetup[<toc style>]{<section type>}{<space above>}{<space below>}{<font>}}.


The \ryuenumsetup command sets up the variables that determine what a heading created with \Item will look like. You can tweak these values if you like to make this match your needs.

Remarks

• Instead of defining a new enumeration environment you could also modify enumerate with \renewlist{enumerate}{enumerate}{5} and \setlist[enumerate,<n>]{…}.

• Currently, the section headings are indented exactly as much as the content below it. This may not work for large numbers at the top level because roman numerals can be quite wide.

• You may wish to also tweak the appearance of the toc a bit. It is by default set up so that the distance between the start of the section numbers and the titles increases with depth because section titles usually stack. From what I hear the tocloft package is good for doing this sort of thing, but I have very little experience with it.

• You can leave the first mandatory parameter of \ryuenumsetup empty, in which case headings at this level won't show up in the table of contents.

• Most of the definition of \Item was taken from the default sectioning commands, but some parts are left out. \Item will thus not behave exactly as a sectioning command. (It most notably won't increment the \<sub*>section counter.)

• +1 @ryuhekai this seems much closer to your desired output, if you do end up using this answer, know that you can (and should) give this the green tick :) – Troy Dec 26 '18 at 15:38
• Wow, this is super useful, thank you! Do you know if it's possible to use this set-up but alter the numbering display in the ToC? The only one I'd like (but don't have as it is somewhat more for aesthetics) to change is the highest level, so that rather than reading "I. Preamble" it would read "Article I: Preamble" and, for the next one, "Article II: Other Text". @Troy your answer still definitely helped a lot, thank you! Quick question re: your set-up, do you know if it would be possible to limit the counting format to a specific section of the document? – ryuhekai Dec 26 '18 at 20:09
• @ryuhekai: I've significantly improved my answer (the spacing in particular has been improved). If you intend to use it you may wish to switch to this version. I've also addressed the toc entry formatting, as requested. – Circumscribe Dec 26 '18 at 22:18
• @ryuhekai: In case you just copied my edited answer: I just discovered that I had forgotten a comma before ref=… at depth 4 and 5. I've fixed this now. – Circumscribe Dec 26 '18 at 22:25
• @Circumscribe I have been successfully using this, though I was wondering how I could reference different items. I have used \label{Item:name} to provide labels to each heading. However, when I attempt to use ~\ref to call the reference, it returns a blank space. I have also tried to change the label to \label{section:name}, which has not worked (I assumed it would not given section was replaced with Item). Do you know how I might accomplish this? Would this need to be defined in the new environment? – ryuhekai Jan 7 at 20:28

Regarding your first issue, they should be \Roman{section}, \Alph{subsection} and \arabic{subsubsection} respectively. Note it is \Alph not \Alpha.

As for your second issue... see the code below. Basically, I check for the current section depth (adapted from Detecting section depth) and set the label based on that value using an \ifcase construct [for more info on \ifcase, @Joseph's answer here should explain things well].

\documentclass[a4paper,12pt]{article}
\usepackage{enumitem}
\usepackage{etoolbox}  % for \pretocmd

\setcounter{secnumdepth}{4} % for "subsubsubsection" <-> paragraph

% Issue 1:
\renewcommand\thesection{\Roman{section}.}
\renewcommand\thesubsection{\Alph{subsection}.}
\renewcommand\thesubsubsection{\alph{subsubsection}.}
\renewcommand\theparagraph{\roman{paragraph}.}

% Issue 2:
\makeatletter
\def\currentsection{0}% initialise
\pretocmd\@startsection{\def\currentsection{#2}}{}{}
\makeatother

\setlist[enumerate]{label={%
\ifcase\currentsection
\Roman*.% if outside section
\or
\Alph*.% section level
\or
\arabic*.% subsection level
\or
\roman*.% subsubsection level
\or
\alph*)% "subsubsub"section level
\fi}
}

\begin{document}
\pagenumbering{arabic}
\title{\huge The Constitution}
\author{\large The Author}
\date{\today}
\maketitle

\tableofcontents

\newpage

\section{Preamble}

\subsection{Name}
We shall be called The Government.

\subsubsection{Subsubsection title}
\begin{enumerate}
\item Enum item 1
\item Enum item 2
\end{enumerate}

\subsubsection{Another Subsubsection}
\begin{enumerate}
\item Enum item 1
\item Enum item 2
\end{enumerate}

\paragraph{The subsubsubsection}
\begin{enumerate}
\item Enum 1
\item Enum 2
\end{enumerate}

\subsection{Another subsection}
\begin{enumerate}
\item Enum item 1
\item Enum item 2
\end{enumerate}

\section{Another section}
Who are the members?
\begin{enumerate}
\item Enum item 1
\item Enum item 2
\end{enumerate}

\section{TOC format}
\begin{enumerate}
\item Enum item 1
\item Enum item 2
\end{enumerate}

\end{document}


• This is amazing! A Christmas Miracle if you will! As a final question, if I wanted to create indentations all the way down (as in my Edit 2 example), what'd be the best way to do that? Would that be renewing a command? – ryuhekai Dec 25 '18 at 23:20
• indentation of the enumerate environments only? or the section/subsection etc. titles must shift as well? – Troy Dec 25 '18 at 23:21
• Having the section/subsection items move as well. – ryuhekai Dec 25 '18 at 23:23
• @ryuhekai that's not my area of expertise unfortunately. probably with titlesec` or related packages. i'm sorry I can't help you with that. if you think my answer is insufficient, feel free to remove the tick. and/or ask a follow-up question linking to this one. – Troy Dec 25 '18 at 23:25
• No your answer was beautiful and has saved me hoooouuuurs of work. Thank you so very very much! I'm sure the indentation question has been asked before, so I'll do some searching. Many many thanks for your help! – ryuhekai Dec 25 '18 at 23:31