这个问题与我之前的章节标题问题
我正在尝试制作一份圣经文本,其中章节和诗句引用出现在每页的页眉中。如以下使用代码生成的 PDF 图片所示:
\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}
当我使用以下代码调用命令 \section{} 时,我能够正确显示标题中的引用。但问题是我的页面布局不如上一个示例那么整洁。
\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}
我怎样才能将这两个选项结合起来?
答案1
下面的代码展示了一种可能的解决方案。我使用\titleformat
和\titlespacing
来格式化节和小节,使其具有所需的布局,因此现在您可以使用\section{}
和\subsection
而不是\bchapter
和\bverse
并获得正确的标记。我还在原语的帮助下定义了两个命令\IndOne
(缩进一行文本)和\IndTwo
(缩进两行文本),\parshape
以获得新节后面行的正确段落形状。
由于您正在使用scrbook
,因此您必须明确设置要使用的标记(book
和的默认设置scrbook
是使用章节和部分),因此您需要\setmarks{section}{subsection}
像我在示例代码中所做的那样添加。
\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}
下面是我的示例代码编译后得到的两个页面: