# Intersperced Step Numbering

Im looking for a package or a way to handle numbering for items arbitrarily spaced through out a document, that can then be referenced later in the document.

My specific case is that I have a document of instructions, and I want to label all the measurement steps with a number (one that automatically increments like sections do), so I can reference that number on a page dedicated to recording measurement results.

I cannot figure out how to make an environment to handle this because the items are not all together.

Example of code.

\newenvironment{zz} %formating for section content, subsections, and their content
{\list{}{
\leftmargin=0.3in
\rightmargin=0in
\itemindent=0in
\listparindent=0in
}
\item\relax}
{\endlist}

\newenvironment{yy} %formating for subsubsections and their content
{\list{}{
\leftmargin=0in
\rightmargin=0in
\itemindent=0in
\listparindent=0in}
\item\relax
}
{\endlist}

\begin{document}
\HereIsSomeTitleStuff

\section{Instructions}
\begin{zz}
Its time for some background text. Leorium uipsume bla bla bla

\subsection{category A}

Here is some details on it.

More details and instructions

Measurement!!!!

More details

\subsection{category B}

Here is some details on it.

More details and instructions

Measurement!!!!

More details

\subsection {category C}

Here is some details on it.

More details and instructions

Measurement!!!!

More details

\end{zz}

\section{Intermediate part of the document}
\begin{zz}

Bla bla bla classified info goes here.

\end{zz}
\section{report forum}
\begin{zz}

space for first measurement

space for second measurement

space for third measurement
\end{zz}
\end document


See where I have "Measurement!!!!". I want those to be numbered in the final .pdf so I can reference the "step" number in the report form. {zz} is for paragraph formatting (indentation, hanging indentation).

• So do you want some special numbering associated with the zz environment? What about yy (since you never use it)? Are these environments really necessary? – Werner Sep 6 '13 at 19:13
• If you know of a better way to format sections, subsections, and all paragraphs, list, and tabular within a document I would love to know. Right now this method (which I got from here) doesn't work with figures and tables, so I dont use any of them. – Bob Sep 6 '13 at 19:21
• What kind of formatting are you interested in? It seems like you're interested in indenting everything below a \section, right? What \documentclass are you using? Are you limited in the packages you can use? – Werner Sep 6 '13 at 19:37
• Right now I am working in an article class. I have miktex installed. The document is typed entirely in unicode so I use xelatex to compile it. – Bob Sep 6 '13 at 19:41
• Originally I was looking for a way to define document formatting parameters at the top of the document and have them automatically apply throughout the document. However, unless I am mistaken, I found that \sections and the like to not actually group (encapsulate parts of) the document. So I created a stripped down \quote environment called {zz} and I manualy encapsulate all the content held within a \section to indent it all. {yy} is the same thing for subsubsections. I have one more called {df} which is for creating definitions with subsequent lines indented. The solutions works pretty well. – Bob Sep 6 '13 at 20:00

Here's a start to your measurement referencing:

\documentclass{article}
\newcounter{measurement}
\newenvironment{measurement}
{\par\refstepcounter{measurement}\noindent
{\ignorespacesafterend}
\begin{document}
\section{Instructions}
Its time for some background text. Leorium uipsume bla bla bla

\subsection{category A}

Here is some details on it.

More details and instructions

\begin{measurement}
Measurement!!!! \label{measurement1}
\end{measurement}

More details

\subsection{category B}

Here is some details on it.

More details and instructions

\begin{measurement}
Measurement!!!! \label{measurement2}
\end{measurement}

More details

\subsection {category C}

Here is some details on it.

More details and instructions

\begin{measurement}
Measurement!!!! \label{measurement3}
\end{measurement}

More details

\section{Intermediate part of the document}

Bla bla bla classified info goes here.

\section{report forum}

\begin{measurement}
space for first measurement. See measurement~\ref{measurement1}.
\end{measurement}

\begin{measurement}
space for second measurement. See measurement~\ref{measurement2}.
\end{measurement}

\begin{measurement}
space for third measurement. See measurement~\ref{measurement3}.
\end{measurement}
\end{document}


This is a very basic implementation that uses a counter spanning the entire document. If you wish to change the way the counter looks, update \themeasurement. If you wish to have the counter reset with (say) \section, that can also be done.

• Would you mind explaining to me how that works? Based upon the order I would have thought the number would be displayed first. You reference refstepcounter before \textbf{Measurement. Also, is ~\the a standard command? Because I dont see any variables called \themeasurement. – Bob Sep 6 '13 at 19:43
• @Bob: \refstepcounter merely steps (increments) the counter and updates \@currentlabel - the thing that is used when you call \label. \themeasurement is the representation of the measurement counter. So, in sequence, we set a new paragraph \par, increment the measurement counter (and make it referenceable) via \refstepcounter, issue a \noindent so the paragraph is not indented, then set the heading in bold font via \textbf (this includes the title Measurement as well as the counter representation \themeasurement & colon), then a \quad space and ignore spaces. – Werner Sep 6 '13 at 19:47
• @Bob: If you use \newcounter{measurement}, LaTeX creates a counter (variable) \c@measurement but also a representation of that counter in the form \themeasurement (default is set to \arabic{measurement}). – Werner Sep 6 '13 at 19:48