Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question is linked to my previous chapter-and-verse-in-header question

I am trying to produce a Bible text where the Chapter and Verse references appear in the header of each page. As can be seen in this picture of the PDF produced with the code below: Example of faulty page

\documentclass[paper=a5,pagesize=pdftex]{scrbook}
\usepackage[pagestyles, compact]{titlesec}
\usepackage{lettrine}

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}

% definition of the page style with required headers
\newpagestyle{Biblestyle}{
  \setheadrule{.009pt}

  \sethead[\thepage][\chaptertitle][\toptitlemarks\thesection:\toptitlemarks\thesubsection---\bottitlemarks\thesection:\bottitlemarks\thesubsection]{\toptitlemarks\thesection:\toptitlemarks\thesubsection---\bottitlemarks\thesection:\bottitlemarks\thesubsection}{\chaptertitle}{\thepage}

}

\pagestyle{Biblestyle}

\newcommand{\bchapter}{%
\setcounter{subsection}{2}%
\addtocounter{section}{1}%
\lettrine{\thesection}{}~%
}

\newcommand{\bverse}{%
\addtocounter{subsection}{1}%
\par
\textbf{\small{\thesubsection}}\quad%
}

\renewcommand{\LettrineFontHook}{\bfseries}

\setlength{\parindent}{0pt}


\begin{document}
\renewcommand{\chaptertitle}{Genesis}

\bchapter In the beginning God created the heaven and the earth.\\
    \textbf{\small{2}}\quad 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.
    \bverse And God said, Let there be light: and there was light.
    \bverse And God saw the light, that it was good: and God divided the light from the darkness.
    \bverse And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.
    \bverse And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.
    \bverse 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.
    \bverse And God called the firmament Heaven. And the evening and the morning were the second day.
    \bverse 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.
    \bverse And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.
    \bverse 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.
    \bverse 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.
    \bverse And the evening and the morning were the third day.

\bchapter Thus the heavens and the earth were finished, and all the host of them.\\
    \textbf{\small{2}}\quad 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.
    \bverse 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.
    \bverse 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,
    \bverse 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.
    \bverse But there went up a mist from the earth, and watered the whole face of the ground.
    \bverse 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.
    \bverse And the LORD God planted a garden eastward in Eden; and there he put the man whom he had formed.
    \bverse 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.
    \bverse And a river went out of Eden to water the garden; and from thence it was parted, and became into four heads.
    \bverse The name of the first is Pison: that is it which compasseth the whole land of Havilah, where there is gold;
    \bverse And the gold of that land is good: there is bdellium and the onyx stone.
    \bverse And the name of the second river is Gihon: the same is it that compasseth the whole land of Ethiopia.
    \bverse 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.
    \bverse And the LORD God took the man, and put him into the garden of Eden to dress it and to keep it.
\renewcommand{\chaptertitle}{Exodus}
\bchapter 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?\\
    \textbf{\small{2}}\quad And the woman said unto the serpent, We may eat of the fruit of the trees of the garden:
    \bverse 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.
    \bverse And the serpent said unto the woman, Ye shall not surely die:
    \bverse 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.
    \bverse 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.
    \bverse 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.
    \bverse 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.
    \bverse And the LORD God called unto Adam, and said unto him, Where art thou?
    \bverse And he said, I heard thy voice in the garden, and I was afraid, because I was naked; and I hid myself.
    \bverse 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?
    \bverse And the man said, The woman whom thou gavest to be with me, she gave me of the tree, and I did eat.
    \bverse 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.
    \bverse 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:
    \bverse 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.
    \bverse 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.

\bchapter And Adam knew Eve his wife; and she conceived, and bare Cain, and said, I have gotten a man from the LORD.\\
    \textbf{\small{2}}\quad And she again bare his brother Abel. And Abel was a keeper of sheep, but Cain was a tiller of the ground.
    \bverse And in process of time it came to pass, that Cain brought of the fruit of the ground an offering unto the LORD.
    \bverse 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:
    \bverse But unto Cain and to his offering he had not respect. And Cain was very wroth, and his countenance fell.
    \bverse And the LORD said unto Cain, Why art thou wroth? and why is thy countenance fallen?
    \bverse 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.
    \bverse 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.
    \bverse And the LORD said unto Cain, Where is Abel thy brother? And he said, I know not: Am I my brother's keeper?
    \bverse And he said, What hast thou done? the voice of thy brother's blood crieth unto me from the ground.
    \bverse And now art thou cursed from the earth, which hath opened her mouth to receive thy brother's blood from thy hand;
    \bverse 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}

I am able to get the references in the header to appear correctly when using the following code where I call the command \section{}. The problem then however is that my page layout is not quite as neat as with the previous example.

enter image description here

\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}

How can I combine the two options?

share|improve this question
    
Just a thought I've had so far is to attempt something with the \stepcounter and \refstepcounter commands. Not sure if this is heading in the right direction though. –  McGafter Aug 24 '11 at 11:34
1  
You could circumvent the problem by using \section and making the sections invisible using titlesec with the explicit option... –  ℝaphink Aug 24 '11 at 12:28

1 Answer 1

up vote 2 down vote accepted

The code below shows one possible solution. I used \titleformat and \titlespacing to format the sections and subsections to have the required layout, so now you can use \section{} and \subsection instead of \bchapter and \bverse and get the right marks. I also defined the two command \IndOne (indents one line of text) and \IndTwo (indents two lines of text) with the help of the \parshape primitive to get the right paragraph shape for the lines following a new section.

Since you are using scrbook, you have to explicitly set the marks to be used (the default for book and scrbook is to use chapter and section), so you need to add \setmarks{section}{subsection} as I did in my example code.

\documentclass[paper=a5,pagesize=pdftex]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[pagestyles]{titlesec}
\usepackage{lettrine}

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}

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

% sets the marks to be used (section and subsection)
\setmarks{section}{subsection}

% sections and subsections formatting
\titleformat{\section}
{}{\lettrine{\thesection}}{0em}{}[\vskip-0.65\baselineskip]
\titleformat{\subsection}[runin]
{\small\bfseries}{\thesubsection}{1em}{}
\titlespacing{\section}{1em}{-1pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{1em}


\pagestyle{Biblestyle}

\renewcommand{\LettrineFontHook}{\bfseries}

\setlength{\parindent}{0pt}

\newlength\NumLen
\newlength\LinLen
% indents one line of text. Indentation= width of section number + 1em
\newcommand\IndOne{%
  \settowidth\NumLen{\thesection}
  \addtolength\NumLen{1em}
  \setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
  \parshape 2 \NumLen \LinLen 0pt \textwidth}
% indents two lines of text. Indentation= width of section number + 1em
\newcommand\IndTwo{%
  \settowidth\NumLen{\thesection}
  \addtolength\NumLen{1em}
  \setlength\LinLen{\dimexpr\textwidth-\NumLen}%\the\NumLen\the\LinLen
  \parshape 3 \NumLen \LinLen \NumLen \LinLen 0pt \textwidth}

\begin{document}
\renewcommand{\chaptertitle}{Genesis}
%
\enlargethispage{3\baselineskip}% optional
\section{}\IndOne In the beginning God created the heaven and the earth.\stepcounter{subsection}
    \subsection{}\IndOne 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{} \IndTwo Thus the heavens and the earth were finished, and all the host of them.\stepcounter{subsection}
    \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.

\renewcommand{\chaptertitle}{Exodus}
\section{}\IndTwo 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?
  \stepcounter{subsection}\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{}\IndTwo And Adam knew Eve his wife; and she conceived, and bare Cain, and said, I have gotten a man from the LORD.
    \stepcounter{subsection}\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}

Here are two of the pages obtained after compilation of my example code:

enter image description here

share|improve this answer
    
Your solution woks brilliant! I figured I wasn't using scrbook properly. I've had limited success with using \documentclass[a5paper]{article} but ended up running into other issues. Thanks a lot. Many thanks also to @Raphink, I've learned a lot about TeX with your help. –  McGafter Aug 24 '11 at 16:10
    
Further to the answer above: To automatically calculate when to use Gonzalo's \IndOne or \IndTwo commands I've used this code: \newlength{\myIndent} \settowidth{\myIndent}{\IndOne In the beginning God created the Heaven and the Earth.} \ifdimless{\the\myIndent} {\textwidth} {\IndOne In the beginning God created the Heaven and the Earth. \stepcounter{subsection} \subsection{}\IndOne And the earth was without form, and void;...} {\IndTwo In the beginning God created the Heaven and the Earth. \stepcounter{subsection} \subsection{} And the earth was without form, and void;...} –  McGafter Aug 29 '11 at 10:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.