[Tex/LaTex] Chapters and verses of current page in header

chaptersheader-footerledmactitlesecverse

This question is linked to my other titlesec question

Does any one know how to add the current segment location at the top of any particular page.

What I need is the reference at the top of a typical Bible page showing which text is on the current page.

For example: If the current page contains part or all of Exodus chapter 15 verse 4 to part or all of Exodus chapter 18 verse 9, the text in the page header alongside the page number needs to show "15:4 – 18:9".

In my search so far I've found references to using the ledmac package.

For example, I think problem at the following url is of a similar kind of problem, but I can't see where the solution to my particular problem is given. http://markmail.org/message/rmylweubecvy4nyp#query:+page:1+mid:3fhvswygyu2tnpo6+state:results

He referenced the following url, but that also does not solve the problem, even though in my limited knowledge, I think it's heading in the right direction. http://www.djdekker.net/ledmac/#bible

===============================================

Additional questions based on Gonzalo's answer:

I am able to get the references in the header with the titlesec package.
The remaining problems are evident from my output.

Example page

The \section{} appears as a number representing the chapter. The \subsection{} appears as another number representing the verse. The ideal would be to format it in the body to show only the chapter number at the first verse and then the numbers 2 and greater for the rest of the verses. In the past when not using titlesec, I was able to get something looking this way by using the lettrine package/command. Please see below:

Example using lettrine

Is it possible to produce the same output using this titlesec package? If not, is it possible to modify the following code to move the chapter number appearing in the left margin down a bit to align it with the first verse?

Furthermore the spacing in between the subsection lines (verses) is a little bit too much. How do I make them a little smaller?

Here is my current code:

\documentclass[a5paper]{article}
\usepackage[pagestyles, compact]{titlesec}
\usepackage{lettrine}

\renewcommand\thesubsection{\arabic{subsection}}

% quick redefinition of \section and \subsection to imitate Bible chapters and verses
%\titleformat{\section}[runin]
%  {\normalfont\normalsize\bfseries}{\Large\thesection}{1em}{}

\titleformat{\section}[leftmargin]
  {\normalfont\Large
    \bfseries\filleft}
   {\thesection}{0em}{}
\titlespacing{\section}
   {-2pc}{-1pc}{1pc}

\titleformat{\subsection}[runin]
  {\normalfont\normalsize\bfseries}{\textsuperscript{\thesubsection}}{1em}{}

% definition of the page style with required headers
\newpagestyle{Biblestyle}{
  \sethead[\toptitlemarks\thesection:\toptitlemarks\thesubsection---\bottitlemarks\thesection:\bottitlemarks\thesubsection]
  []
  [\thepage]
  {\thepage}
  {}
  {\toptitlemarks\thesection:\toptitlemarks\thesubsection---\bottitlemarks\thesection:\bottitlemarks\thesubsection}}
\pagestyle{Biblestyle}

\begin{document}
\section{}
    \subsection{} In the beginning God created the heaven and the earth.
    \subsection{} 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.
    \subsection{} And God said, Let there be light: and there was light.
    \subsection{} And God saw the light, that it was good: and God divided the light from the darkness.
    \subsection{} And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.
    \subsection{} And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.
    \subsection{} And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.
    \subsection{} And God called the firmament Heaven. And the evening and the morning were the second day.
    \subsection{} And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.
    \subsection{} And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.
    \subsection{} And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.
    \subsection{} And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.
    \subsection{} And the evening and the morning were the third day.
\section{}
    \subsection{} Thus the heavens and the earth were finished, and all the host of them.
    \subsection{} And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.
    \subsection{} And God blessed the seventh day, and sanctified it: because that in it he had rested from all his work which God created and made.
    \subsection{} These are the generations of the heavens and of the earth when they were created, in the day that the LORD God made the earth and the heavens,
    \subsection{} And every plant of the field before it was in the earth, and every herb of the field before it grew: for the LORD God had not caused it to rain upon the earth, and there was not a man to till the ground.
    \subsection{} But there went up a mist from the earth, and watered the whole face of the ground.
    \subsection{} And the LORD God formed man of the dust of the ground, and breathed into his nostrils the breath of life; and man became a living soul.
    \subsection{} And the LORD God planted a garden eastward in Eden; and there he put the man whom he had formed.
    \subsection{} And out of the ground made the LORD God to grow every tree that is pleasant to the sight, and good for food; the tree of life also in the midst of the garden, and the tree of knowledge of good and evil.
    \subsection{} And a river went out of Eden to water the garden; and from thence it was parted, and became into four heads.
    \subsection{} The name of the first is Pison: that is it which compasseth the whole land of Havilah, where there is gold;
    \subsection{} And the gold of that land is good: there is bdellium and the onyx stone.
    \subsection{} And the name of the second river is Gihon: the same is it that compasseth the whole land of Ethiopia.
    \subsection{} And the name of the third river is Hiddekel: that is it which goeth toward the east of Assyria. And the fourth river is Euphrates.
    \subsection{} And the LORD God took the man, and put him into the garden of Eden to dress it and to keep it.
\section{}
    \subsection{} Now the serpent was more subtil than any beast of the field which the LORD God had made. And he said unto the woman, Yea, hath God said, Ye shall not eat of every tree of the garden?
    \subsection{} And the woman said unto the serpent, We may eat of the fruit of the trees of the garden:
    \subsection{} But of the fruit of the tree which is in the midst of the garden, God hath said, Ye shall not eat of it, neither shall ye touch it, lest ye die.
    \subsection{} And the serpent said unto the woman, Ye shall not surely die:
    \subsection{} For God doth know that in the day ye eat thereof, then your eyes shall be opened, and ye shall be as gods, knowing good and evil.
    \subsection{} And when the woman saw that the tree was good for food, and that it was pleasant to the eyes, and a tree to be desired to make one wise, she took of the fruit thereof, and did eat, and gave also unto her husband with her; and he did eat.
    \subsection{} And the eyes of them both were opened, and they knew that they were naked; and they sewed fig leaves together, and made themselves aprons.
    \subsection{} And they heard the voice of the LORD God walking in the garden in the cool of the day: and Adam and his wife hid themselves from the presence of the LORD God amongst the trees of the garden.
    \subsection{} And the LORD God called unto Adam, and said unto him, Where art thou?
    \subsection{} And he said, I heard thy voice in the garden, and I was afraid, because I was naked; and I hid myself.
    \subsection{} And he said, Who told thee that thou wast naked? Hast thou eaten of the tree, whereof I commanded thee that thou shouldest not eat?
    \subsection{} And the man said, The woman whom thou gavest to be with me, she gave me of the tree, and I did eat.
    \subsection{} And the LORD God said unto the woman, What is this that thou hast done? And the woman said, The serpent beguiled me, and I did eat.
    \subsection{} And the LORD God said unto the serpent, Because thou hast done this, thou art cursed above all cattle, and above every beast of the field; upon thy belly shalt thou go, and dust shalt thou eat all the days of thy life:
    \subsection{} And I will put enmity between thee and the woman, and between thy seed and her seed; it shall bruise thy head, and thou shalt bruise his heel.
    \subsection{} Unto the woman he said, I will greatly multiply thy sorrow and thy conception; in sorrow thou shalt bring forth children; and thy desire shall be to thy husband, and he shall rule over thee.
\section{}
    \subsection{} And Adam knew Eve his wife; and she conceived, and bare Cain, and said, I have gotten a man from the LORD.
    \subsection{} And she again bare his brother Abel. And Abel was a keeper of sheep, but Cain was a tiller of the ground.
    \subsection{} And in process of time it came to pass, that Cain brought of the fruit of the ground an offering unto the LORD.
    \subsection{} And Abel, he also brought of the firstlings of his flock and of the fat thereof. And the LORD had respect unto Abel and to his offering:
    \subsection{} But unto Cain and to his offering he had not respect. And Cain was very wroth, and his countenance fell.
    \subsection{} And the LORD said unto Cain, Why art thou wroth? and why is thy countenance fallen?
    \subsection{} If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him.
    \subsection{} And Cain talked with Abel his brother: and it came to pass, when they were in the field, that Cain rose up against Abel his brother, and slew him.
    \subsection{} And the LORD said unto Cain, Where is Abel thy brother? And he said, I know not: Am I my brother's keeper?
    \subsection{} And he said, What hast thou done? the voice of thy brother's blood crieth unto me from the ground.
    \subsection{} And now art thou cursed from the earth, which hath opened her mouth to receive thy brother's blood from thy hand;
    \subsection{} When thou tillest the ground, it shall not henceforth yield unto thee her strength; a fugitive and a vagabond shalt thou be in the earth.

\end{document}

Best Answer

Here's a possible solution using the \toptitlemarks, \bottitlemarks mechanism of the titlesec package:

\documentclass[twoside]{article}
\usepackage[pagestyles]{titlesec}

\renewcommand\thesubsection{\arabic{subsection}}

% quick redefinition of \section and \subsection to imitate Bible chapters and verses
\titleformat{\section}[runin]
  {\normalfont\normalsize\bfseries}{\Huge\thesection}{1em}{}
\titleformat{\subsection}[runin]
  {\normalfont\normalsize\bfseries}{\textsuperscript{\thesubsection}}{1em}{}

% definition of the page style with required headers
\newpagestyle{Biblestyle}{
  \sethead[\toptitlemarks\thesection:\toptitlemarks\thesubsection---%
    \bottitlemarks\thesection:\bottitlemarks\thesubsection]
  []
  [\thepage]
  {\thepage}
  {}
  {\toptitlemarks\thesection:\toptitlemarks\thesubsection---%
    \bottitlemarks\thesection:\bottitlemarks\thesubsection}}
\pagestyle{Biblestyle}

% a command to generate some filler text
\newcommand\Text{Lorem ipsum sit amet, consectetuer elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}

\begin{document}

\section{}
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
\section{}
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text\Text\Text\Text\Text\Text\Text\Text\Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text
\section{}
    \subsection{} \Text
    \subsection{} \Text
    \subsection{} \Text

\end{document}

enter image description here

The subsection mark in the first page is not showing correctly (it's not showing at all), but my code could give you some ideas as how to proceed.

Related Question