How to add a counter to beginning of each sentence like the Bible?

1 In the beginning God created the
heaven and the earth.  2 And the
earth was without form, and void;
and darkness was upon the face of
the deep. And the Spirit of God
moved upon the face of the waters.

3 And God said, "Let there be
light," and there was light.  4 God
saw that the light was good, and
he separated the light from the
darkness.  5 God called the light
"day," and the darkness he called
"night." And there was evening,
and there was morning-the first day.


as above.

-

You can use a short name for this frequently used command, say \?. This command takes an optional argument, in case you have to jump over some verses.

\documentclass[a4paper]{article}

\newcounter{versecount}
\newcommand{\?}[1][0]{%
\ifnum#1=0
\stepcounter{versecount}%
\else
\setcounter{versecount}{#1}%
\fi
\textsuperscript{\theversecount}\ignorespaces
}
\newcommand{\versereset}{\setcounter{versecount}{0}}

\begin{document}
\? In the beginning God created the heaven and the earth.

\? And the earth was without form, and void; and darkness
was upon the face of the deep. And the Spirit of God moved
upon the face of the waters.

\? And God said, Let there be light,'' and there was light.
\? God saw that the light was good, and he separated the
light from the darkness.
\? God called the light day,'' and the darkness he called
night.'' And there was evening, and there was morning---the
first day.

\?[31] And God saw every thing that he had made, and, behold,
it was very good. And the evening and the morning were the
sixth day.

\end{document}


The command \versereset makes the counter start anew from 1 at the following appearance of \?. This may be added to a \biblechapter command for adding a chapter title.

-
Isn't \versereset\? ··· equivalent to \?[1] ···, making \versereset superfluous? (No criticism intended, just my minimalist tic appearing) –  Brent.Longborough Nov 20 '11 at 11:49
@Brent.Longborough No, it isn't, as \?[1] also prints 1. –  egreg Nov 20 '11 at 11:58
But why would you want to reset it without printing it? –  Brent.Longborough Nov 20 '11 at 13:57
@Brent.Longborough: As mentioned in @ egreg's post ending, you may want to include \versereset as a patch to other document commands to automate the process of counter versecounter renewal. That way you don't have to explicitly start every chapter with \?[1], as \? would be equivalent to \?[1] (just at the start of the chapter). –  Werner Nov 20 '11 at 16:11
Would you want \refstepcounter? –  cmhughes Nov 20 '11 at 16:20
show 3 more comments

First of all you may define a new command, for numbering:

\newcounter{sentence}
\newcommand*{\nextsentence}{\refstepcounter{sentence}\textsuperscript{\thesentence}\ignorespaces}


This may be used at the start of each sentence. But this wouldn't be handy, so a short hand would be nice. This could be defined using babel:

\documentclass[twocolumn]{article}
\usepackage[english]{babel}

\newcounter{sentence}
\newcommand*{\nextsentence}{\refstepcounter{sentence}\textsuperscript{\thesentence}\ignorespaces}

\useshorthands{'}
\defineshorthand{'S}{\nextsentence}
\defineshorthand{'.}{. \nextsentence}

\begin{document}
'S In the beginning God created the
heaven and the earth'.   And the
earth was without form, and void;
and darkness was upon the face of
the deep. And the Spirit of God
moved upon the face of the waters.

'S And God said, "Let there be
light," and there was light'.   God
saw that the light was good, and
he separated the light from the
darkness'. God called the light
"day," and the darkness he called
"night." And there was evening,
and there was morning-the first day.
\end{document}


As you can see, I've replaced every ., that should be followed by a new sentence number, by '.. That's the new short hand, to set a '.' followed by a new sentence number.

You could make . active to have auto numbering:

\newcommand*{\dotatend}{}
\let\dotatend. % to be used e.g. at the end of a paragraph

\catcode\.=\active
\def.{\dotatend\space\nextsentence}


But this may result in several problems (because . is used at numbers). So I wouldn't recommend it.

To number sentences, that are not prefixed by a ., I've defined a second short hand 'S. You may automate the sentence number at the start of a paragraph using \everypar:

\documentclass[twocolumn]{article}
\usepackage[english]{babel}

\newcounter{sentence}
\newcommand*{\nextsentence}{\refstepcounter{sentence}\textsuperscript{\thesentence}\ignorespaces}

\useshorthands{'}
\defineshorthand{'S}{\nextsentence}
\defineshorthand{'.}{. \nextsentence}

\newenvironment{withsentencenumber}{%
\par
\everypar{\nextsentence}%
}{%
\par
}

\begin{document}
\begin{withsentencenumber}
In the beginning God created the
heaven and the earth'.   And the
earth was without form, and void;
and darkness was upon the face of
the deep. And the Spirit of God
moved upon the face of the waters.

And God said, "Let there be
light," and there was light'.   God
saw that the light was good, and
he separated the light from the
darkness'. God called the light
"day," and the darkness he called
"night." And there was evening,
and there was morning-the first day.
\end{withsentencenumber}
\end{document}


But note, that LaTeX itself uses \everypar at several places, so this automatism may be deactivated using environments like lists inside the new environment withsentencenumber. If so, you may end the environment and begin a new one to reactivate the automatism.

BTW: Package scrjura uses something like the above for numbering of paragraphs and sentences. Currently there seams to be only a German documentation for the package. Usage of babel has been suggested at that manual.

-
You could probably just add one to the counter automatically at the beginning of the withsentencenumber` environment. This would go wrong if you used the environment with no content, but I don't think that would be a serious shortcoming. –  qubyte Nov 20 '11 at 10:53
Ah, no, I see why that wouldn't be enough now. Nice solution though. I really like this. –  qubyte Nov 20 '11 at 10:56