![每个偶数页上都有章节编号的方框](https://linux22.com/image/364532/%E6%AF%8F%E4%B8%AA%E5%81%B6%E6%95%B0%E9%A1%B5%E4%B8%8A%E9%83%BD%E6%9C%89%E7%AB%A0%E8%8A%82%E7%BC%96%E5%8F%B7%E7%9A%84%E6%96%B9%E6%A1%86.png)
答案1
您可以在页面发货过程中通过以下方式将随机内容放置在页面上eso-pic
。
下面的示例将章节号(用 表示\thechapter
)插入到页面右侧垂直居中的位置。\showchapterthumb<TF>
如果设置为 ,则附加条件将启用章节号缩略图的显示\..true
。默认值为\..false
。
\documentclass{report}
\usepackage{lipsum}
\usepackage{eso-pic,xcolor}
\definecolor{chapterthumbbg}{HTML}{6F7175}
\AddToShipoutPictureFG{%
\AtPageLowerLeft{%
\ifshowchapterthumb\ifodd\value{page}\else
\makebox[\paperwidth][r]{%
\raisebox{\dimexpr.5\paperheight-.5\height}{%
\setlength{\fboxsep}{\baselineskip}%
\colorbox{chapterthumbbg}{\textcolor{white}{\thechapter}}%
}%
}%
\fi\fi
}
}
\newif\ifshowchapterthumb
\sloppy% Just for this document
\begin{document}
\showchapterthumbfalse% Default
\tableofcontents
\clearpage
\showchapterthumbtrue% Show chapter thumbs
\chapter{First chapter}\lipsum[1-5]
\section{First section}\lipsum[6-10]
\section{Second section}\lipsum[11-15]
\section{Third section}\lipsum[16-20]
\section{Last section}\lipsum[21-25]
\chapter{Second chapter}\lipsum[1-5]
\section{First section}\lipsum[6-10]
\section{Second section}\lipsum[11-15]
\section{Third section}\lipsum[16-20]
\section{Last section}\lipsum[21-25]
\chapter{Third chapter}\lipsum[1-5]
\section{First section}\lipsum[6-10]
\section{Second section}\lipsum[11-15]
\section{Third section}\lipsum[16-20]
\section{Last section}\lipsum[21-25]
\chapter{Last chapter}\lipsum[1-5]
\section{First section}\lipsum[6-10]
\section{Second section}\lipsum[11-15]
\section{Third section}\lipsum[16-20]
\section{Last section}\lipsum[21-25]
\end{document}
添加背景页码仅仅是为了视觉目的。
答案2
像这样? 用 很容易 titleps
,它带有titlesec
:
\documentclass[12pt, twoside]{book}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\newpagestyle{mine}{%
\widenhead[2em][0em]{0em}{0em}
\sethead[\smash{\colorbox{SlateGrey!70}{\rule[-1.5ex]{0pt}{5ex}\sffamily\Large\bfseries\thechapter}}][][]{}{}{}
\setfoot{}{}{}
}
\pagestyle{mine}
\begin{document}
\chapter{introduction}
\lipsum[1-8]
\end{document}
变体:将页面样式定义为
\newpagestyle{thine}{%
\widenhead[2em][0em]{0em}{0em}
\sethead[\raisebox{-\dimexpr\headsep+\headheight+2ex\relax} {\colorbox{SlateGrey!70}{\rule[-1.5ex]{0pt}{5ex}\sffamily\Large\bfseries\thechapter}}][][]{}{}{}
\setfoot{}{}{}
}
编辑:我想我明白你想要什么了。这段代码能达到你想要的效果吗?
\newpagestyle{midpage}{%
\widenhead[2em][0em]{0em}{0em}
\sethead[\raisebox{-\dimexpr\headsep+\headheight+0.5\textheight\relax}{\colorbox{SlateGrey!70}{\parbox{1.4em}{\centering\rule[-2.8ex]{0pt}{8ex}\sffamily\Large\bfseries\thechapter}}}][][]{}{}{}
\setfoot{}{}{}
}
\pagestyle{midpage}