A numbered environment for example sentences

I want an environment for example sentences where sentences are numbered and can be referenced. This is common in publications in the area of linguistics and there are a few packages that do the trick. But here is my own.

First, we need a counter that provides the number for the sentence:

\newcounter{mySentence}

We reset sentence counter for each chapter:

\@addtoreset{mySentence}{chapter}

We print the sentence number as (chapter.sentence):

\renewcommand*{\themySentence}{(\thechapter.\arabic{mySentence})}

Then we define an environment for one example sentence, where the number will be printed in the beginning of the line and then the sentence follows:

\newcommand{\backskip}{\vspace{-0.4\baselineskip}}
\newenvironment{examplesentence}
{% start env
\backskip%
\stepcounter{mySentence}%
\begin{enumerate} \small%
\renewcommand{\theenumi}{\thechapter.\arabic{mySentence}}%
\renewcommand{\labelenumi}{\themySentence}%
\itemsep0pt \parskip0pt%
\item
}
{% end env
\end{enumerate}
\backskip
}

Next is an environment for more than one example sentence. Here the sentence number will be printed in the beginning of the line and the individual sentences get an a., b., c., in front of them:

\newenvironment{examplesentences}
{% start env
\begin{examplesentence}%
\begin{enumerate} \itemsep0pt \parskip0pt%
\renewcommand{\theenumii}{\alph{enumii}}%
\renewcommand{\labelenumii}{\alph{enumii}.}%
}
{% end env
\end{enumerate}
\end{examplesentence}
}
This entry was posted in LaTeX and tagged , by swk. Bookmark the permalink.

About swk

I am a computational linguist, teacher of computer science and above all a huge fan of LaTeX. I use LaTeX for everything, including things you never wanted to do with LaTeX. My latest love is lilypond, aka LaTeX for music. I'll post at irregular intervals about cool stuff, stupid hacks and annoying settings I want to remember for the future.