编辑:

编辑:

我正在使用此代码作为标题标记,但正如您所看到的,它错过了该小节的第一个标记,而该标记应该是第一节。

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

结果发现,第一部分的诗句引用缺失了:

在此处输入图片描述

有没有一种简单的方法来检查当为\firsttitlemarks\thesubsection空(或等于空或类似值)时将其替换为值“1”。

我一直在尝试\ifdefempty这个etoolbox包但它似乎没有像我预期的那样工作。

编辑:

\documentclass[paper=a5,pagesize=pdftex]{scrbook}
\usepackage[top=2cm,bottom=1.5cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lettrine}
\usepackage{xltxtra}
\usepackage{tocloft}
%\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage[toc]{multitoc}
\usepackage{setspace}

\defaultfontfeatures{Mapping=tex-text}
%\setmainfont{Times New Roman}
\setmainfont{Cardo}

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

% definition of the page style with required headers
\newpagestyle{Biblestyle}{
  \setheadrule{.02pt}
  \sethead[\thepage][\chaptertitle][\firsttitlemarks\thesection:\ifnumcomp{\value{subsection}}{>}{1}{\firsttitlemarks\thesubsection}{1}---\bottitlemarks\thesection:\bottitlemarks\thesubsection]{\firsttitlemarks\thesection:\ifnumcomp{\value{subsection}}{>}{1}{\firsttitlemarks\thesubsection}{1}---\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-1\baselineskip]
\titleformat{\subsection}[runin]
{\small\bfseries}{\thesubsection}{1em}{}
\titlespacing{\section}{1em}{-1pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{1em}

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

\usepackage[none]{hyphenat}
\sloppy
\usepackage{hyperref}
\hypersetup{
    bookmarksdepth=1,
    unicode=true,
    colorlinks=true,
    citecolor={black},
    linkcolor={black},
    urlcolor={black},
    pdffitwindow=true,
    pdftitle={The Holy Bible}
}

\addtokomafont{disposition}{\rmfamily\mdseries}

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\contentsname}{Table of Contents}
\renewcommand*\cfttoctitlefont{\huge\hfill}
\renewcommand*\cftaftertoctitle{\hfill}
\renewcommand{\cftchapdotsep}{\cftdot}
%\setlength{\cftpartindent}{\hfill}
\renewcommand{\cftpartfont}{\hfill\bfseries}
\renewcommand{\cftchapfont}{\mdseries}
\renewcommand{\cftpartpagefont}{\hfill\footnotesize\bfseries}
\renewcommand{\cftchappagefont}{\mdseries}
\setlength{\cftbeforetoctitleskip}{-4em}
\setlength{\cftaftertoctitleskip}{3em}
\setlength{\cftbeforechapskip}{.3em}
\setlength{\cftbeforepartskip}{.3em}
\setlength{\columnsep}{2pc}
\setlength\columnseprule{.4pt}

%\dottedcontents{chapter}[2.5em]{}{2.3em}{1pc}
\begin{document}
\frontmatter
    % Titlepage
        \pdfbookmark[0]{Titlepage}{title}
    \title{}
    \subject{
        \vspace{3cm}
        \textbf{\Large{THE}\\\vspace{-0.3cm}
        \Huge{HOLY}\\\vspace{0.05cm}
        \Huge{BIBLE}}\\\vspace{0.5cm}
    }
    \maketitle

\cleardoublepage
\setcounter{tocdepth}{0}
\pdfbookmark[0]{\contentsname}{tofcontents}
\begin{spacing}{0.01}
\tableofcontents
\end{spacing}
\cleardoublepage

\mainmatter
\pagestyle{Biblestyle}
\newlength{\myIndent}
\begin{center}
\setcounter{section}{0}
\phantomsection
\addcontentsline{toc}{part}{Old Testament}\noindent
\phantomsection
\addcontentsline{toc}{chapter}{Genesis}\noindent
THE FIRST BOOK OF MOSES, CALLED\\
\vspace{0.15cm}\textbf{\Huge{GENESIS}}\vspace{0.00cm}\\

\end{center}
\renewcommand{\chaptertitle}{Genesis}

\pdfbookmark[1]{1}{01O1}
\section{}
\settowidth{\myIndent}
{\IndOne In the beginning God created the heaven and the earth.}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\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.}
{\IndTwo In the beginning God created the heaven and the earth. \stepcounter{subsection} \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.
\subsection{} And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:
\subsection{} And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.
\subsection{} And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.
\subsection{} And God set them in the firmament of the heaven to give light upon the earth,
\subsection{} And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.
\subsection{} And the evening and the morning were the fourth day.
\subsection{} And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.
\subsection{} And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.
\subsection{} And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.
\subsection{} And the evening and the morning were the fifth day.
\subsection{} And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.
\subsection{} And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good.
\subsection{} And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.
\subsection{} So God created man in his own image, in the image of God created he him; male and female created he them.
\subsection{} And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth.
\subsection{} And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat.
\subsection{} And to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so.
\subsection{} 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.

\pdfbookmark[1]{2}{01O2}
\section{}
\settowidth{\myIndent}
{\IndOne Thus the heavens and the earth were finished, and all the host of them.}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\IndOne Thus the heavens and the earth were finished, and all the host of them. \stepcounter{subsection} \subsection{} \IndOne 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.}
{\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 \textsc{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 \textsc{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 \textsc{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 \textsc{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 \textsc{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 \textsc{Lord} God took the man, and put him into the garden of Eden to dress it and to keep it.
\subsection{} And the \textsc{Lord} God commanded the man, saying, Of every tree of the garden thou mayest freely eat:
\subsection{} But of the tree of the knowledge of good and evil, thou shalt not eat of it: for in the day that thou eatest thereof thou shalt surely die.
\subsection{} And the \textsc{Lord} God said, It is not good that the man should be alone; I will make him an help meet for him.
\subsection{} And out of the ground the \textsc{Lord} God formed every beast of the field, and every fowl of the air; and brought them unto Adam to see what he would call them: and whatsoever Adam called every living creature, that was the name thereof.
\subsection{} And Adam gave names to all cattle, and to the fowl of the air, and to every beast of the field; but for Adam there was not found an help meet for him.
\subsection{} And the \textsc{Lord} God caused a deep sleep to fall upon Adam and he slept: and he took one of his ribs, and closed up the flesh instead thereof;
\subsection{} And the rib, which the \textsc{Lord} God had taken from man, made he a woman, and brought her unto the man.
\subsection{} And Adam said, This is now bone of my bones, and flesh of my flesh: she shall be called Woman, because she was taken out of Man.
\subsection{} Therefore shall a man leave his father and his mother, and shall cleave unto his wife: and they shall be one flesh.
\subsection{} And they were both naked, the man and his wife, and were not ashamed.

\pdfbookmark[1]{3}{01O3}
\section{}
\settowidth{\myIndent}
{\IndOne Now the serpent was more subtil than any beast of the field which the \textsc{Lord} God had made. And he said unto the woman, Yea, hath God said, Ye shall not eat of every tree of the garden?}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\IndOne Now the serpent was more subtil than any beast of the field which the \textsc{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{} \IndOne And the woman said unto the serpent, We may eat of the fruit of the trees of the garden:}
{\IndTwo Now the serpent was more subtil than any beast of the field which the \textsc{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 \textsc{Lord} God walking in the garden in the cool of the day: and Adam and his wife hid themselves from the presence of the \textsc{Lord} God amongst the trees of the garden.
\subsection{} And the \textsc{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 \textsc{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 \textsc{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.
\subsection{} And unto Adam he said, Because thou hast hearkened unto the voice of thy wife, and hast eaten of the tree, of which I commanded thee, saying, Thou shalt not eat of it: cursed is the ground for thy sake; in sorrow shalt thou eat of it all the days of thy life;
\subsection{} Thorns also and thistles shall it bring forth to thee; and thou shalt eat the herb of the field;
\subsection{} In the sweat of thy face shalt thou eat bread, till thou return unto the ground; for out of it wast thou taken: for dust thou art, and unto dust shalt thou return.
\subsection{} And Adam called his wife's name Eve; because she was the mother of all living.
\subsection{} Unto Adam also and to his wife did the \textsc{Lord} God make coats of skins, and clothed them.
\subsection{} And the \textsc{Lord} God said, Behold, the man is become as one of us, to know good and evil: and now, lest he put forth his hand, and take also of the tree of life, and eat, and live for ever:
\subsection{} Therefore the \textsc{Lord} God sent him forth from the garden of Eden, to till the ground from whence he was taken.
\subsection{} So he drove out the man; and he placed at the east of the garden of Eden Cherubims, and a flaming sword which turned every way, to keep the way of the tree of life.

\begin{center}
\setcounter{section}{0}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Exodus}\noindent
THE SECOND BOOK OF MOSES, CALLED\\
\vspace{0.15cm}\textbf{\Huge{EXODUS}}\vspace{0.00cm}\\

\end{center}
\renewcommand{\chaptertitle}{Exodus}

\pdfbookmark[1]{1}{02O1}
\section{}
\settowidth{\myIndent}
{\IndOne Now these are the names of the children of Israel, which came into Egypt; every man and his household came with Jacob.}
\ifdimless{\the\myIndent}
{.99\textwidth}
{\IndOne Now these are the names of the children of Israel, which came into Egypt; every man and his household came with Jacob. \stepcounter{subsection} \subsection{} \IndOne Reuben, Simeon, Levi, and Judah,}
{\IndTwo Now these are the names of the children of Israel, which came into Egypt; every man and his household came with Jacob. \stepcounter{subsection} \subsection{} Reuben, Simeon, Levi, and Judah,}
\subsection{} Issachar, Zebulun, and Benjamin,
\subsection{} Dan, and Naphtali, Gad, and Asher.
\subsection{} And all the souls that came out of the loins of Jacob were seventy souls: for Joseph was in Egypt already.
\subsection{} And Joseph died, and all his brethren, and all that generation.
\subsection{} And the children of Israel were fruitful, and increased abundantly, and multiplied, and waxed exceeding mighty; and the land was filled with them.
\subsection{} Now there arose up a new king over Egypt, which knew not Joseph.
\subsection{} And he said unto his people, Behold, the people of the children of Israel are more and mightier than we:
\subsection{} Come on, let us deal wisely with them; lest they multiply, and it come to pass, that, when there falleth out any war, they join also unto our enemies, and fight against us, and so get them up out of the land.
\subsection{} Therefore they did set over them taskmasters to afflict them with their burdens. And they built for Pharaoh treasure cities, Pithom and Raamses.
\subsection{} But the more they afflicted them, the more they multiplied and grew. And they were grieved because of the children of Israel.
\subsection{} And the Egyptians made the children of Israel to serve with rigour:
\subsection{} And they made their lives bitter with hard bondage, in morter, and in brick, and in all manner of service in the field: all their service, wherein they made them serve, was with rigour.
\subsection{} And the king of Egypt spake to the Hebrew midwives, of which the name of the one was Shiphrah, and the name of the other Puah:
\subsection{} And he said, When ye do the office of a midwife to the Hebrew women, and see them upon the stools; if it be a son, then ye shall kill him: but if it be a daughter, then she shall live.
\subsection{} But the midwives feared God, and did not as the king of Egypt commanded them, but saved the men children alive.
\subsection{} And the king of Egypt called for the midwives, and said unto them, Why have ye done this thing, and have saved the men children alive?
\subsection{} And the midwives said unto Pharaoh, Because the Hebrew women are not as the Egyptian women; for they are lively, and are delivered ere the midwives come in unto them.
\subsection{} Therefore God dealt well with the midwives: and the people multiplied, and waxed very mighty.
\subsection{} And it came to pass, because the midwives feared God, that he made them houses.
\subsection{} And Pharaoh charged all his people, saying, Every son that is born ye shall cast into the river, and every daughter ye shall save alive.

\end{document}

答案1

我无法用最小示例重现预期结果,但我推测\ifthesubsection(参见手册)是您想要的(只是猜测)。顺便说一句,\...titlemarks是开关,一旦激活,您就不需要重复它们。

相关内容