2

I've been working on a custom title presentation for my document for titles \part{}, \chapter{}, \section{} and paragraph{}. I also use the extension shorttoc to make a summary at the start of my document and then display the full table of content at the end of it.

My problem is both my shorttoc and my toc are not displayed like my other styles. I would like them to be displayed like a \part{} but I can't figure how to do it.

I've searched on the Internet and found something not similar but still with the same objective. The following code was proposed to help her solve her problem:

\makeatletter
\def\@cftmaketoctitle{\chapter*{\contentsname}}
\makeatother

I didn't find a working solution with this because the asker was using the tocloft extension and I'm using shorttoc and the normal \tableofcontents

I firstly replaced \chapter* by \part* because I would like to have my title as a \part.

Then I get trouble with \@cftmaketoctitle. I tried to compile my document with it but didn't notice any change. So I tried it by replacing it with \@shorttableofcontents and \@cftshorttableofcontents like this, without seeing any change:

\makeatletter
\def\@shorttableofcontents{\part*{\contentsname}}
\makeatother

I'm new at LaTeX programming and have trouble to understand this \@, I've understood that \def is the TeX equivalent of \newcommand in LaTeX but I struggle to go farther.

Can anyone of you help me to design my shorttoc and toc title as a part?

Here is my MWE :

\documentclass[11pt,a4paper,oneside,openright]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}% Pour générer du faux texte}
\usepackage{shorttoc}% Gestion du sommaire
\usepackage{titlesec}
\usepackage[french]{babel}% Pour un document en français

% --------------------------------------------------
% Paramétrage des parties
% --------------------------------------------------
\titleclass{\part}{top}
\titleformat{\part}[frame]
    {\null\vspace{.10\textheight}\normalfont}
    {\fillright
    \enspace PARTIE~\thepart\enspace}
    {8pt}
    {\huge\bfseries\filcenter\textsc}

\titlespacing{\part}{0pt}{*0}{*5}

\renewcommand\thepart{\arabic{part}}


\begin{document}
    \part{Here is a part}
    \lipsum

    \shorttableofcontents{Sommaire}{1}

    \part*{Introduction}
    \addcontentsline{toc}{chapter}{Introduction}
    \markboth{Introduction}{Introduction}
    \lipsum

    \nocite{*}
    \printbibliography
    \addcontentsline{toc}{chapter}{Bibliographie}

    \tableofcontents
\end{document}
5
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – jub0bs
    Commented Aug 15, 2014 at 21:59
  • Generally spoken, all commands starting with \@ or having a @ are internal commands, not needed for a users who do not plan to write a new package or document class, and therefore, they are somehow hidden, not being usable in a real document. They can be made available using the \makeatletter command (very simplified just now). However those commands are called anyway, by using other, non @-commands.
    – user31729
    Commented Aug 16, 2014 at 3:36
  • Thank you for the advice, I added a MWE. :) Thank you for the information Christian Hupfer, I didn't know it.
    – Berhthun
    Commented Aug 16, 2014 at 11:42
  • Thank you very much, your solution is working. :) Sorry for the errors in the MWE, I got a pdf file in output so i thought it was good. You can give the exact answer you put in your last comment so I can mark you as resolved if you want. :)
    – Berhthun
    Commented Aug 17, 2014 at 0:26
  • @Berhthun: If your are working with hyperref package, you will additionally need \phantomsection commands before \addcontentsline statements, to correct the link targets etc.
    – user31729
    Commented Aug 17, 2014 at 9:04

1 Answer 1

1

The easiest solution to the problem is to copy the \titleformat{part} and say \titleformat{chapter} with the appropiate changes. This will suffice, since \tableofcontents and \shorttableofcontents use a \chapter*{} command to write the \contentsname title.

However, this will set the style for usual \chapters as well.

Code

\documentclass[11pt,a4paper,oneside,openright]{book}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}% Pour générer du faux texte}
\usepackage{shorttoc}% Gestion du sommaire
\usepackage{titlesec}
\usepackage[french]{babel}% Pour un document en français
\usepackage{biblatex} % Most probably for \printbibliography

% --------------------------------------------------
% Paramétrage des parties
% --------------------------------------------------
\titleclass{\part}{top}
\titleformat{\part}[frame]
    {\null\vspace{.10\textheight}\normalfont}
    {\filright
    \enspace PARTIE~\thepart\enspace}
    {8pt}
    {\huge\bfseries\filcenter\textsc}

\titleclass{\chapter}{top}
\titleformat{\chapter}[frame]
    {\null\vspace{.10\textheight}\normalfont}
    {\filright
    \enspace Chapitre~\thechapter\enspace}
    {8pt}
    {\huge\bfseries\filcenter\textsc}



\titlespacing{\part}{0pt}{*0}{*5}




\renewcommand\thepart{\arabic{part}}


\begin{document}
    \part{Here is a part}
    \lipsum

    \shorttableofcontents{Sommaire}{1}

    \part*{Introduction}
    \addcontentsline{toc}{chapter}{Introduction}
    \markboth{Introduction}{Introduction}
    \lipsum

    \nocite{*}
    \printbibliography
    \addcontentsline{toc}{chapter}{Bibliographie}



    \tableofcontents
\end{document}

Sorry for bad knowledge of French ;-)

Screenshots

enter image description here enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .