0

I'm quite happy with titlesec and titleps for keeping track of sections and creating footers that are conditional on whether a chapter start or is continued, but there was a case where it wasn't straightforward to obtain a custom format. So, what I'm looking to do is decouple sectioning from its format. As a workaround, for now, I just want to disable any typesetting of \chapter{...}. In the example below, this means getting rid only of "Chapter 1\nl Fonts", such that "SOME CUST CHAP. FORMAT" comes at the top of the same page.

\documentclass{report}
\usepackage{fontawesome}
\usepackage{lastpage}
\usepackage{tabularx}
\usepackage{titlesec}
\usepackage{titleps}
\usepackage{xparse}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\NewDocumentCommand{\thedoc}
{}% Is there not a command for `token list` in xparse?
{THIS DOC}

\NewDocumentCommand{\myheaderii}
{+mm}
{%
  \begin{tabularx}{\textwidth}{@{}XR@{}}#1&#2\end{tabularx}
}  
\NewDocumentCommand{\myheaderiii}
{+mmm}
{%
  \begin{tabularx}{\textwidth}{@{}X@{}C@{}R@{}}#1&#2&#3\end{tabularx}
}  
\NewDocumentCommand{\chapterMark}{}{UNDEFINED!}
\NewDocumentCommand{\setchapterMark}{m}
{%
  \RenewDocumentCommand{\chapterMark}{}{#1}
}
%\setcounter{chapter}{0}
\NewDocumentCommand{\newChapter}{mmO{}}
{%
  % \stepcounter{chapter}
  \chapter{#1}
  \setchapterMark{#2}

  SOME CUST CHAP. FORMAT%THAT NO EXISTING PACKAGE CAN EASILY MAKE
  \textless#1\textgreater
}
% pagestyle--------------------------------------------------------
\newpagestyle{specialii}
{
  \setfoot{%
    \myheaderii{\thedoc}{\thepage/\pageref{LastPage}}%
  }{}{}
}
\newpagestyle{specialiii}
{
  \setfoot{%
    \myheaderiii{\thedoc}{\chapterMark}{\thepage/\pageref{LastPage}}%
  }{}{}
}

\assignpagestyle{\chapter}{specialii}

\begin{document}
\pagestyle{specialiii}
%\pagestyle{empty}
\begin{titlepage}\vspace*{\fill}\huge\begin{center}\thedoc\end{center}\vspace*{\fill}\end{titlepage}

\newChapter{Fonts}{\faFont}

Let's make that span\newpage another page

\end{document} 

Shot Shot Shot

  • What you want is not clear to me. From the image, I'd say maybe you want another formatting for unnumbered chapters like the table of contents index, &c. Could you explain more? – Bernard Oct 7 at 8:21
  • I want \chapter to create a chapter, just not display it. That way, I can use whatever functionality is associated with \chapter (in this case \assignpagestyle{\chapter}{specialii}), and customize the display of the chapter. – Erwann Oct 7 at 8:28
  • 1
    If your special chapter is unnumbered, you can define another formatting and spacing with the numberless key, different from the formatting and spacing for numbered chapters, if it can help. – Bernard Oct 7 at 8:51
  • Would I still have to use titleformat? I stated explicitly it was not suitable. – Erwann Oct 7 at 17:22
  • I have some difficulty to make out what you want. Must some chapters have only their title, without any label? And must the chapter counter nevertheless be increased? – Bernard Oct 7 at 17:54
1

Here is a proposition, certainly to be adjusted, as some questions have to be answered: will the chapter title replacement text be a fixed text for all such layouts or will it be just a new chapter title without the label? What about the tableof contents and the header/footer?

 \documentclass{report}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage[a6paper, margin=20pt, bottom=34pt, footskip=24pt, showframe]{geometry}
    \usepackage{fontawesome5}
    \usepackage{lastpage}
    \usepackage{lipsum} % Dummy Text
    \usepackage[pagestyles, explicit]{titlesec}
    \usepackage{xparse, etoolbox}
    \usepackage{tabularx}
    \usepackage{hyperref}

    \renewcommand*\familydefault{\sfdefault}

    \NewDocumentCommand{\chapterLabel}{}{Ch. \thechapter}
    \NewDocumentCommand{\chapterMark}{}{U HAVE TO DEFINE IT!}
    \NewDocumentCommand{\setchapterMark}{m}
    {%
      \RenewDocumentCommand{\chapterMark}{}{#1}
    }%

    \newcolumntype{R}{>{\raggedleft\arraybackslash}X}

    \newpagestyle{main}{%
      \setfoot{\thepage/\pageref{LastPage}}{}{\chapterLabel}
    }%

    \newpagestyle{special}{%
      \setfoot{\thepage/\pageref{LastPage}}{}{\chapterMark}
    }%
\newtoggle{nodisplay} 

\titleformat{\chapter}{\thispagestyle{empty}\sffamily\large}{\iftoggle{nodisplay}{}{\rlap{\makebox[\textwidth][r]{Ch. \thechapter}}}}{0em}{\iftoggle{nodisplay}{\vspace*{-8.5ex}}{#1}}[\leavevmode\togglefalse{nodisplay}]
    \titlespacing*{\chapter}{0pt}{-3ex}{4ex}%-5ex

    \pagestyle{main}

    \begin{document}

    \title{Lorem Ipsum}
    \author{Dolor S. Amet}
    \maketitle
    %
    \chapter{Gibberish}
    %
    \lipsum[1-5]{
     \toggletrue{nodisplay}
    \chapter{More Gibberish}}
SOME CUSTOM TITLE \par
    \lipsum[6-12]
    \clearpage

    \chapter{Still More Gibberish}
    \lipsum[6-12]
    \clearpage

    \setchapterMark{\faBook}
    \pagestyle{special}
    \chapter*{Bibliography}
    Let's make that
    \newpage
     ... span a second page

    \end{document} 

enter image description here

  • PS: Upon re-flexion it doesn't work. It's going to be hard to give a MWE for what I really want to do. I do know that I don't want \chapter to print absolutely nothing. – Erwann Oct 8 at 3:51
0

Here's my attempt at adapting @Bernard's answer the MWE of this post:

\documentclass{report}
\usepackage{fontawesome}
\usepackage[showframe]{geometry}
\usepackage{lastpage}
\usepackage{tabularx}
\usepackage[explicit]{titlesec}
\usepackage{titleps}
\usepackage{xparse,etoolbox}

\makeatletter\def\@makechapterhead#1{}\makeatother

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\NewDocumentCommand{\thedoc}
{}% Is there not a command for `token list` in xparse?
{THIS DOC}

\NewDocumentCommand{\myheaderii}
{+mm}
{%
  \begin{tabularx}{\textwidth}{@{}XR@{}}#1&#2\end{tabularx}
}  
\NewDocumentCommand{\myheaderiii}
{+mmm}
{%
  \begin{tabularx}{\textwidth}{@{}X@{}C@{}R@{}}#1&#2&#3\end{tabularx}
}  
\NewDocumentCommand{\chapterMark}{}{UNDEFINED!}
\NewDocumentCommand{\setchapterMark}{m}
{%
  \RenewDocumentCommand{\chapterMark}{}{#1}
}
%\setcounter{chapter}{0}
\NewDocumentCommand{\newChapter}{mmO{}}
{%
  \setchapterMark{#2}
  \chapter{#1}
}
% pagestyle--------------------------------------------------------
\newpagestyle{specialii}
{
  \setfoot{%
    \myheaderii{\thedoc}{\thepage/\pageref{LastPage}}%
  }{}{}
}
\newpagestyle{specialiii}
{
  \setfoot{%
    \myheaderiii{\thedoc}{\chapterMark}{\thepage/\pageref{LastPage}}%
  }{}{}
}

\newtoggle{nodisplay} 

\titleformat{\chapter}
{
  \thispagestyle{specialii}
  \sffamily\large
}
{
  \iftoggle{nodisplay}
  {}
  {
  }
}
{0em}
{
  \iftoggle{nodisplay}
  {
    %\vspace*{-8.5ex}
  }
  {SOME CUST CHAP. FORMAT%THAT NO EXISTING PACKAGE CAN EASILY MAKE
  \textless#1\textgreater}
}[\leavevmode\togglefalse{nodisplay}]

\titlespacing*{\chapter}{0pt}{-3ex}{0ex}%-5ex

\begin{document}
\pagestyle{specialiii}
\begin{titlepage}\vspace*{\fill}\huge\begin{center}\thedoc\end{center}\vspace*{\fill}\end{titlepage}

\newChapter{Fonts}{\faFont}

Let's make that span\newpage another page

\end{document} 

Shot 1 Shot 2 Shot 3

0

Here's an answer that is closer to the problem specification as it disables the display of the chapter header, and that only. I gave an example here in which customizing chapter header through titleformat probably not doable. I added the toc to show it is unaffected. A few cosmetic TODO's remain within the code...

\documentclass{report}
\usepackage[french]{babel} % added to problem specification
\usepackage{fontawesome}
\usepackage[showframe]{geometry}
\usepackage{lastpage}
\usepackage{tabularx}
\usepackage{titleps}
\usepackage{xparse}
\usepackage{xpatch}

%https://tex.stackexchange.com/questions/511253/how-can-i-keep-sectioning-but-disable-its-display

%disabling chapter display----------------------------------------
% \makeatletter\def\@makechapterhead#1{}\makeatother
% This one does:
\usepackage{xpatch}
\tracingpatches
\makeatletter % the macro name contains @
\patchcmd{\@chapter}{\if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}{}{}{}
\makeatother

%-----------------------------------------------------------------
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\NewDocumentCommand{\thisdoc}
{}% TODO Is there not a command for `token list` in xparse?
{THIS DOC}

\NewDocumentCommand{\myheaderii}
{+mm}
{%
  \begin{tabularx}{\textwidth}{@{}XR@{}}#1&#2\end{tabularx}
}  
\NewDocumentCommand{\myheaderiii}
{+mmm}
{%
  \begin{tabularx}{\textwidth}{@{}X@{}C@{}R@{}}#1&#2&#3\end{tabularx}
}  
\NewDocumentCommand{\chapterMark}{}{UNDEFINED!}
\NewDocumentCommand{\setchapterMark}{m}
{%
  \RenewDocumentCommand{\chapterMark}{}{#1}
}
\NewDocumentCommand{\newChapter}{mmO{}}
{%
  \setchapterMark{#2}
  \chapter{#1}
  \thispagestyle{specialii}
  {SOME CUST CHAP. FORMAT%THAT NO EXISTING PACKAGE CAN EASILY MAKE
  \textless#1\textgreater}
}

%-----------------------------------------------------------------
\newpagestyle{specialii}
{
  \setfoot{%
    \myheaderii{\thisdoc}{\thepage/\pageref{LastPage}}%
  }{}{}
}
\newpagestyle{specialiii}
{
  \setfoot{%
    \myheaderiii{\thisdoc}{\chapterMark}{\thepage/\pageref{LastPage}}%
  }{}{}
}

\begin{document}%-------------------------------------------------
\thispagestyle{empty}
\begin{titlepage}\vspace*{\fill}\huge\begin{center}\thisdoc\end{center}\vspace*{\fill}\end{titlepage}
\tableofcontents
\pagestyle{specialiii}
\newChapter{Writing}{\faPencil}

Let's make that span\newpage another page

\newChapter{Fonts}{\faFont}

Fonts are great.

\end{document} 

EDIT on 10/10:

  • Replaced the crude modification on internals of \chapter with one using \patchcmd.

  • Added \usepackage[french]{babel}, which causes problems (french added to the chapter title), hence

  • Unchecked this answer

Shot 1 Shot 2 Shot 3 Shot 4 Shot 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.