带有出血线下的页码的页眉样式

带有出血线下的页码的页眉样式

我正在尝试在文档中创建这种标题样式memoir(这是 Inkscape 中的模型):

目标标题样式

我想到过tikz,也见过很酷的一个,但我认为这并不是那么复杂,tikz对于每个标题来说也许都是多余的。

我想不出如何做到这一点:

  • 彩色框中页眉下的页码
  • 降低头部规则(默认刚好在头部基线下方)
  • 规则和页码出血 3 毫米至页边距

我已经到了这一步:

已经到了这一步

布局等代码在 Github 上,准备编译。处理标头的部分位于theheaders.sty

\nouppercaseheads

\newlength\BOOK@bleed
\setlength{\BOOK@bleed}{3mm}

\newlength\BOOK@headWidth
\newlength\BOOK@footWidth

% TODO: header should bleed on each side
%\setlength{\BOOK@headWidth}{\textwidth + 2\foremargin + 2\BOOK@bleed}
\setlength{\BOOK@headWidth}{\textwidth + 2\foremargin}
\setlength{\BOOK@footWidth}{\textwidth}

\makepagestyle{toprightnum}

\makerunningwidth{toprightnum}[\BOOK@footWidth]{\BOOK@headWidth}
\makeheadposition{toprightnum}{center}{center}{center}{center}
\makeheadrule{toprightnum}{\BOOK@headWidth}{0.5pt}

\newcommand\headerFmt{\headerFont\headerSize\color{header}}
\newcommand\pageNumFmt{\pageNumFont\pageNumSize\color{pagenum}}

% TODO: page number should drop under the headrule with a gray
% background

\makeoddhead{toprightnum}%
{\headerFmt%
  \hspace*{\foremargin}\MakeLowercase{\rightmark}}%
{}%
{\headerFmt%
  \MakeLowercase{\leftmark}%
  \parbox[c][][t]{\foremargin}{%
    \pageNumFmt%
    \mbox{}\hfill\textbf{\thepage}\hfill\mbox{}%
  }%
}

\makeevenhead{toprightnum}%
{\headerFmt%
  \parbox[c][][t]{\foremargin}{%
    \pageNumFmt%
    \mbox{}\hfill\textbf{\thepage}\hfill\mbox{}%
  }%
  \MakeLowercase{\leftmark}%
}%
{}%
{\headerFmt%
  \MakeLowercase{\rightmark}\hspace*{\foremargin}%
}

\makeoddfoot{toprightnum}{}{}{}
\makeevenfoot{toprightnum}{}{}{}

\makepsmarks{toprightnum}{%
  \def\chaptermark##1{%
    \markboth{##1}{\rightmark}}%
  \def\partmark##1{%
    \markright{##1}{}}%
  \let\sectionmark\@gobble
}

答案1

xcoffins发现这个设计,之后就变得轻而易举了:

解决了

\nouppercaseheads

\newlength\BOOK@bleed
\setlength{\BOOK@bleed}{3mm}

\NewCoffin\headerWrap
\NewCoffin\headerText
\NewCoffin\headerRule
\NewCoffin\headerPageNum

\newlength\BOOK@headWidth
\newlength\BOOK@headExtra
\setlength{\BOOK@headExtra}{2em}
\setlength{\BOOK@headWidth}{\textwidth + \BOOK@headExtra}

\makepagestyle{toprightnum}

\makerunningwidth{toprightnum}{\BOOK@headWidth}
\makeheadposition{toprightnum}{flushright}{flushleft}{center}{center}

\newcommand\headerFmt{\headerFont\headerSize\color{header}}
\newcommand\pageNumFmt{\pageNumFont\pageNumSize\color{pagenum}}

\makeoddhead{toprightnum}%
{%
  \SetHorizontalCoffin\headerText{%
    \parbox{\BOOK@headWidth}{%
      \headerFmt%
      \MakeLowercase{\rightmark}%
      \hfill%
      \MakeLowercase{\leftmark}%
    }%
  }%
  \SetHorizontalCoffin\headerRule{%
    \color{headrule}\rule{\paperwidth + 2\BOOK@bleed}{0.5pt}%
  }%
  \SetHorizontalCoffin\headerPageNum{%
    \setlength{\fboxsep}{0pt}%
    \colorbox{headrule}{\parbox[t][25pt][c]{\foremargin - \BOOK@headExtra + \BOOK@bleed}{%
      \raggedright
      \hspace*{15pt}%
      \pageNumFmt%
      \textbf{\thepage}%
    }}%
  }%
  \JoinCoffins\headerWrap\headerText
  \JoinCoffins*\headerWrap[l,b]\headerRule[l,t]({-\spinemargin-\BOOK@bleed},-2\onelineskip)%
  \JoinCoffins*\headerWrap[r,b]\headerPageNum[l,t](0pt,-2\onelineskip)%
  \TypesetCoffin\headerWrap
}{}{}%

\makeevenhead{toprightnum}%
{%
  \SetHorizontalCoffin\headerText{%
    \parbox{\BOOK@headWidth}{%
      \headerFmt%
      \MakeLowercase{\leftmark}%
      \hfill%
      \MakeLowercase{\rightmark}%
    }%
  }%
  \SetHorizontalCoffin\headerRule{%
    \color{headrule}\rule{\paperwidth + 2\BOOK@bleed}{0.5pt}%
  }%
  \SetHorizontalCoffin\headerPageNum{%
    \setlength{\fboxsep}{0pt}%
    \colorbox{headrule}{\parbox[t][25pt][c]{\foremargin - \BOOK@headExtra + \BOOK@bleed}{%
      \raggedleft
      \pageNumFmt%
      \textbf{\thepage}%
      \hspace*{15pt}%
    }}%
  }%
  \JoinCoffins\headerWrap\headerText
  \JoinCoffins*\headerWrap[l,b]\headerRule[l,t]({-\foremargin+\BOOK@headExtra-\BOOK@bleed},-2\onelineskip)%
  \JoinCoffins*\headerWrap[l,b]\headerPageNum[r,t](0pt,-2\onelineskip)%
  \TypesetCoffin\headerWrap
}{}{}%

\makeoddfoot{toprightnum}{}{}{}
\makeevenfoot{toprightnum}{}{}{}

\makepsmarks{toprightnum}{%
  \def\chaptermark##1{%
    \markboth{##1}{\rightmark}}%
  \def\partmark##1{%
    \markright{##1}{}}%
  \let\sectionmark\@gobble
}

相关内容