正文外面带有图形页码的页眉

正文外面带有图形页码的页眉

我正在使用 LuaLaTex 格式化一本书。我需要获取如下标题 在此处输入图片描述在此处输入图片描述 我正在使用 titlesec 包。因此我需要页码超出标准 \textwidth。到目前为止,我能做的最好的事情是

\documentclass[10pt]{book}

\usepackage{fontspec}
%\setmainfont[Ligatures=TeX]{Apollo MT}

\usepackage[svgnames]{xcolor}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}% environment for colored and framed text boxes with a heading line

\usepackage[vcentering, hcentering, inner=10.5mm,outer=10.5mm,top=25.5mm, bottom=25.5mm,showframe]{geometry} % Extended page layout customization
\geometry{papersize={189mm,246mm}} % Possible dimensions of textbook pages

 %Page headers
%colored box for page numbers
\newtcbox{\mypagenum}{enhanced,nobeforeafter,tcbox raise base,boxrule=1pt,top=0mm,bottom=0mm,
  colframe=red,coltext=black,colback=white, halign = right,
    width=2.55cm,arc=3.5mm, sharp corners=west, boxsep=2mm,
  } 


\newpagestyle{main}{
   \sethead[][][\thesection~\sectiontitle~\mypagenum\thepage]  % even
           {\mypagenum\thepage Chapter \thechapter\chaptertitle}{}{} % odd
           }
\pagestyle{main}

\begin{document}

\chapter{My title}
\lipsum[20-30]
\section{My Section}
\lipsum[20-30]
\end{document}

我找不到一种(简单的)方法来扩展页眉宽度或定位页码,例如使用 \hspace{-XXcm}。

答案1

解决方案是\widenhead*来自的命令titleps和两个对称的 \tcboxes:

\documentclass[10pt]{book}

\usepackage{fontspec}
%\setmainfont[Ligatures=TeX]{Apollo MT}

\usepackage[svgnames]{xcolor}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}% environment for colored and framed text boxes with a heading line

\usepackage[vcentering, hcentering, inner=10.5mm,outer=10.5mm,top=25.5mm, bottom=25.5mm,showframe]{geometry} % Extended page layout customization
\geometry{papersize={189mm,246mm}} % Possible dimensions of textbook pages

 %Page headers
%colored box for page numbers
\newtcbox{\mypagenum}{enhanced, nobeforeafter, tcbox raise base, boxrule=1pt, top=0mm, bottom=0mm,
  colframe=red, coltext=black, colback=white, halign = right,
    width=2.55cm, arc=3.5mm, sharp corners=west, boxsep=2mm,
  }

\newtcbox{\mypagenumb}{enhanced, nobeforeafter, tcbox raise base, boxrule=1pt, top=0mm, bottom=0mm,
  colframe=red, coltext=black, colback=white, halign=right,
    width=2.55cm, arc=3.5mm, sharp corners=east, boxsep=2mm,
  }

\newpagestyle{main}{%
\widenhead*{0cm}{\dimexpr 1cm+1.5pt}
   \sethead[\mypagenum\thepage~Chapter\,\thechapter\enspace\chaptertitle][][] % even
           {}{}{\thesection~\sectiontitle~\mypagenumb\thepage} % odd
           }
\pagestyle{main}

\begin{document}

\chapter{My title}
\lipsum[20-30]
\section{My Section}
\lipsum[20-30]

\end{document} 

在此处输入图片描述 在此处输入图片描述

相关内容