这是我的代码。出了点问题。
\documentclass{book}
\usepackage{titling}
\usepackage{lastpage}
\usepackage{titleps}
\newpagestyle{main}
{
\sethead[\footnotesize \sffamily{Page}\thepage\ \sffamily{of}\ \pageref{LastPage}]
[\sffamily{\sectiontitle}]
[\textsection\ \thesection]
{\sffamily{Chapter\ \thechapter}}
{\sffamily{\chaptertitle}}
{\footnotesize \sffamily{Page} \thepage\ \sffamily{of}\ \pageref{LastPage}}
}
\pagestyle{main}
\usepackage{titlesec}
\titleformat{\chapter}{\normalfont\LARGE\sf}{\thechapter}{1em}{}
\titleformat{\section}{\normalfont\Large\sf}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\large\sf}{\thesubsection}{1em}{}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{blindtext}
\begin{document}
\chapter{Test Chapter}
\blindmathpaper
\section{title}
\blindmathpaper
\end{document}
使用 TeXstudio 构建,我得到了这个:
line 104: Package titlesec Error: Incompatible package. \fi}
line 111: Package titlesec Error: Incompatible package. ... {\@tempswatrue\ttl@newmk@i\@empty}}
line 194: Package titlesec Error: Incompatible package. ...rks{\@ifstar\ttl@svmarks@s\ttl@svmarks@x}
line 199: Package titlesec Error: Incompatible package. ...ommand\setmarks[2]{\settitlemarks{#1,#2}}
line 243: Package titlesec Error: Incompatible package. {\ttl@pretitlemark\@ne}}
line 253: Package titlesec Error: Incompatible package. \newcommand\headrule{\setheadrule{.4\p@}}
line 254: Package titlesec Error: Incompatible package. \newcommand\footrule{\setfootrule{.4\p@}}
line 261: Package titlesec Error: Incompatible package. \fi}
line 267: Package titlesec Error: Incompatible package. \fi}
line 316: Package titlesec Error: Incompatible package. \newcommand\usepage{\protect\thepage}
line 318: Package titlesec Error: Incompatible package. ...expandafter\@secondoftwo\firstmark{}{}{}}
line 331: Package titlesec Error: Incompatible package. ...{\expandafter\@secondoftwo\botmark{}{}{}}
line 332: Package titlesec Error: Incompatible package. ...s{\expandafter\@firstoftwo\botmark{}{}{}}
line 342: Package titlesec Error: Incompatible package. \fi}
line 352: Package titlesec Error: Incompatible package. \fi}
line 363: Package titlesec Error: Incompatible package. \newcommand\setfoot{\ttl@setany\ttl@setfoot}
line 364: Package titlesec Error: Incompatible package. \newcommand\sethead{\ttl@setany\ttl@sethead}
你能帮助我吗?
答案1
titlesec
和的手册titleps
没有显示不兼容性,但建议同时加载两者
\usepackage[pagestyles]{titlesec}
titleps
——那么就不需要特殊加载了。
\documentclass{book}
\usepackage{titling}
\usepackage{lastpage}
\usepackage[pagestyles]{titlesec}
\newpagestyle{main}
{%
\sethead[\footnotesize \sffamily{Page}\thepage\ \sffamily{of}\ \pageref{LastPage}]
[\sffamily{\sectiontitle}]
[\textsection\ \thesection]
{\sffamily{Chapter\ \thechapter}}
{\sffamily{\chaptertitle}}
{\footnotesize \sffamily{Page} \thepage\ \sffamily{of}\ \pageref{LastPage}}
}
\pagestyle{main}
\titleformat{\chapter}{\normalfont\LARGE\sf}{\thechapter}{1em}{}
\titleformat{\section}{\normalfont\Large\sf}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\large\sf}{\thesubsection}{1em}{}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{blindtext}
\begin{document}
\chapter{Test Chapter}
\blindmathpaper
\section{title}
\blindmathpaper
\end{document}