Fancyhdr 图书类别

Fancyhdr 图书类别

我创建了一个带有运行标题的文件。目前,它仅捕获每个项目的最后一次出现。我希望左侧显示第一次出现,右侧显示最后一次出现。

如果章节从页面中间开始,我该如何让它显示上一页的章节?例如,如果第 5 章从页面中间开始,并且页面的第一部分包含第 4 章的文本,则应显示“4:8–5:4”。

我已附加一个 MWE 工作示例。

    \documentclass[12pt]{book}
    
    \usepackage{dblfnote}
    \usepackage[para]{footmisc}
    \usepackage{ragged2e}
    \usepackage{fontspec}
    \usepackage{ifthen}
    \usepackage{lipsum}
    \usepackage{polyglossia}
    \usepackage{fancyhdr}
    
    % \setmainlanguage{syriac}
    % \setmainfont[BoldFont={DejaVu Serif Bold}]{Serto Antioch Bible}
    
    \setmainlanguage{hebrew}
    \setmainfont{SBLBibLit}
    
    % Make Counters for Chapters and Verses
    \newcommand{\hebtitle}
    \newcounter{mychapter}
    \newcounter{bibver}
    \setcounter{mychapter}{0}
    \setcounter{bibver}{0}
    
    % Make Bible Chapter and Verses
    \newcommand{\mychaptermark}{}
    \newcommand{\bibvermark}{}
    
    \newcommand{\mychapter}[1]{%
      \stepcounter{mychapter}% Increment the mychapter counter
      \renewcommand{\mychaptermark}{#1}%
      \chaptermark{#1 : \bibvermark}% Include the verse number in the chaptermark
      {\centering{#1}}% Center the chapter title
    }
    
    \newcommand{\bibver}[1]{%
      \stepcounter{bibver}% Increment the bibver counter
      \textsuperscript{\textbf{#1}}%
      \renewcommand{\bibvermark}{#1}% Set bibvermark
    }
    
    % Make Book Title in English and Syriac
    \newcommand{\englishtitle}[1]{\centering\LR{#1}}
    \newcommand{\Hebrewtitle}[1]{\centering}
    % Define custom commands for English and Syriac titles
    
    % \newcommand{\syriactitle}{Syriac Title}
    
    \let\oldfootnote\footnote
    \renewcommand{\footnote}[1]{\oldfootnote{~#1}}
    
    % Customize header using fancyhdr
    \pagestyle{fancy}
    \fancyhead{} % Clear previous header settings
    \fancyhead[CO]{\englishtitle}
    \fancyhead[CE]{\hebtitle}
    \fancyhead[RO,LE]{\mychaptermark:\bibvermark –– \mychaptermark:\bibvermark} % Right on odd pages, Left on even pages
    %\fancyhead[RE,LO]{\bibvermark} % Right on even pages, Left on odd pages
    
    \begin{document}
    
    \englishtitle{Genesis}
    \Hebrewtitle{ברשׁית}
    \mychapter{1}
    \bibver{1}בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃
    \bibver{2}וְהָאָ֗רֶץ הָיְתָ֥ה תֹ֨הוּ֙ וָבֹ֔הוּ וְחֹ֖שֶׁךְ עַל־פְּנֵ֣י תְהֹ֑ום וְר֣וּחַ אֱלֹהִ֔ים מְרַחֶ֖פֶת עַל־פְּנֵ֥י הַמָּֽיִם׃
    
    \mychapter{2}
    
    \mychapter{3}
    
    \end{document}

答案1

编辑:已解决。必须使用\extramarks包来捕获所有必要内容。我使用和\leftmark\rightmark跟踪章节,使用\leftxmark\rightxmark来跟踪诗句编号。

\documentclass[12pt]{book}
\usepackage[paperwidth=6in, paperheight=9in, margin=1in]{geometry}

\usepackage{dblfnote}
\usepackage[para]{footmisc}
\usepackage{ragged2e}
\usepackage{fontspec}
\usepackage{ifthen}
\usepackage{polyglossia}
\usepackage{fancyhdr}
\usepackage{extramarks}

\setmainlanguage{syriac}
\setmainfont[BoldFont={DejaVu Serif Bold}]{Serto Antioch Bible}

% Make Counters for Chapters and Verses
\newcommand{\currbook}{}
\newcounter{mychapter}
\newcounter{bibver}
\setcounter{mychapter}{0}
\setcounter{bibver}{0}

% Make Bible Chapter and Verses
\newcommand{\mychaptermark}{}
\newcommand{\bibvermark}{}

\newcommand{\mychapter}[1]{%
  \stepcounter{mychapter}% Increment the mychapter counter
  \renewcommand{\mychaptermark}{#1}%
  %\chaptermark{#1 : \bibvermark}% Include the verse number in the chaptermark
  \markboth{#1}{#1}
  {\centering{#1}}% Center the chapter title
}

\newcommand{\bibver}[1]{%
  \stepcounter{bibver}% Increment the bibver counter
  \extramarks{#1}{#1}% Set both left and right marks to #1
  \textsuperscript{\textbf{#1 }}~%
}


% Make Book Title in English and Syriac
\newcommand{\englishtitle}[1]{\centering\LR{#1}}
\newcommand{\syriactitle}[1]{\centering{#1}}

% Footnotes

% \let\oldfootnote\footnote
% \renewcommand{\footnote}[1]{\oldfootnote{~#1}}

\newcommand{\mymarks}{%
\ifthenelse{\equal{\leftmark}{\rightmark}}
{\leftmark} % if equal
{\leftmark--\rightmark}} % if not equal 

% Set the headheight and potentially adjust topmargin
\setlength{\headheight}{14.5pt} % Adjust this value as needed
\addtolength{\topmargin}{-2.5pt} % Adjust this value as needed

% Customize header using fancyhdr
\pagestyle{fancy}
\fancyhead{} % Clear previous header settings
\fancyhead[CO]{\englishtitle}
\fancyhead[CE]{ܐܓܪܬܐ ܕܝܘܚܢܢ ܫܠܝܚܐ}
\fancyhead[RO,LE]{\leftmark:\lastleftxmark –– \rightmark:\firstrightxmark} % Right on odd pages, Left on even pages


\begin{document}


\end{document}

相关内容