[Tex/LaTex] Package titlesec Error: Incompatible packageļ¼Ÿ

errorspackagestitlesec

Here is my code. Something goes wrong.


\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}

Built with TeXstudio, and I got this:


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}

Would you please help me with it?

Best Answer

The manual of titlesec and titleps does not reveal an incompatibility, but recommends to load both together as

\usepackage[pagestyles]{titlesec} -- the special loading of titleps isn't necessary then.

\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}