我想手动格式化我的书的页眉,奇数页上有章节名称和编号,偶数页上有章节名称和编号,如下图所示
答案1
解决方案如下titlesec/titleps
:
\documentclass[12pt, openany]{book}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[x11names]{xcolor}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\newpagestyle{mine}{%
\newcommand*\hdrformat{\color{SlateGray4}\sffamily}
\sethead[\hdrformat\thesection~\sectiontitle\,$\mathbf]$][][\hdrformat\thepage.]{\hdrformat\thepage.}{}{\hdrformat$[$\,\chaptername~\thechapter}
\setfoot{}{}{}
}
\pagestyle{mine}
\begin{document}
\setcounter{page}{1}
\chapter{First Chapter}
\lipsum[1-3]
\section{My Section}
\lipsum[4-8]
\end{document}