Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

To complete my memory, I would like to display different numbering format beetween my section in the body of my document and the one in the toc

You will find just below my MWE :

\documentclass{book}

\usepackage{titlesec}
\usepackage{shorttoc}
\usepackage{lipsum}

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

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

\renewcommand\thechapter{\arabic{chapter}}

% --------------------------------------------------
% Paramétrage des sections (chapitres)
% --------------------------------------------------
\titleclass{\section}{straight}
\titleformat{\section}[block]
    {\normalfont\huge\bfseries}
    {\textsc{Chapitre}~\thesection~:}
    {2.3ex plus.2ex}
    {\huge}

\titlespacing{\section}{0pt}{*1.5}{*3}

\renewcommand\thesection{\arabic{section}}

% --------------------------------------------------
% Document
% --------------------------------------------------

\begin{document}
    \chapter{Test chapter 1}
    \lipsum[1]
    \shorttableofcontents{Sommaire}{1}
    \chapter{Test chapter 2}
        \lipsum[1]
        \section{Test section 1}
        \lipsum[1]
    \tableofcontents
\end{document}

Everything is looking good in the document except in the toc.

I have this for the moment :

1 Test chapter 1 1
2 Test chapter 2 5
    1 Test section 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

And I would like to have this without any change in my text content :

1 Test chapter 1 1
2 Test chapter 2 5
    2.1 Test section 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

I found a question on the same problem on Different section numbering styles for toc and body.

The MWE document is working great but I can't make it work in mine. I've commented all the lines linked to \titleclass \titleformat \titlespacing in my document, and used the package corrected in the answer but it doesn't reproduce good, I just have one element in the numbering format wanted for a paragraph and I don't have the numerotation of the parents sections.

After this failed test, I tried to go in another way. I tried to adapt it to what I want directly by commenting \title... like previously and edited the aglc.sty file but I didn't see any change at all in the numerotation, I didn't succeed to display a 1.1 format type in my section.

Can anyone help me with this ? Thank you very much in advance. :)


edit after Bernard comment :

Sorry for the confusion about chapter and section headings. I had to do this because of the style headings og shorttoc toc and bibtex because I need to have the style of a part like these elements. This is the reason that pushed me to had a 'Partie' title in a chapter and a 'Chapitre' title in a section.

If I type :

\chapter{Hello world}
    \section{I'm a robot}

I would like to have in my body

Partie 1 : Hello World

Chapitre 1 : I'm a robot

This work nicely but with my configuration, I get this in my shorttoc and toc :

1 Hello World
    1 I'm a robot

and I would like to have :

1 Hello World
    1.1 I'm a robot

Without seeing anychange in my document presentation. It would be like having two different format numerotation for my section, one for shorttoc and toc with the type \thechapter.\thesection and one for the content that is just \thesection.

share|improve this question
    
Welcome to TeX-SX Berhthun. I took the liberty to paste the linked question directly so that it is prettified automatically. –  percusse Aug 17 at 20:22

2 Answers 2

up vote 3 down vote accepted

Here's the changed "section block" with all your "wishes" and also some "guiding" comments (mainly from the titlesec documentation):

% --------------------------------------------------
% Paramétrage des sections (chapitres)
% --------------------------------------------------
\titleclass{\section}{straight}
\titleformat
    {\section}  % command (to be formatted)
    [block]  % shape
    {\normalfont\huge\bfseries}  % format for label and text
    {}  % label (before text)
    {2.3ex plus.2ex} % horiz. space betw. label and text
    {}  % code before text
    []  % code after text

\titlespacing{\section}{0pt}{*1.5}{*3}

% Change the LaTeX internal section label
% Standard in document class "book": \thechapter.\arabic{section}
\renewcommand\thesection{\thechapter.\arabic{section}}

As you might have seen, I've removed also the "code before text" because huge was already set three lines above.

share|improve this answer
    
Thank you for your answer. If your solution correct my problem in the toc, it doesn't stay the same in my document. I get a "Chapitre 2 : Test section 1" in my document and I would like to just have "Test section 1". –  Berhthun Aug 18 at 10:43
    
@Berhthun You have to leave {\textsc{Chapitre}~\thesection~:} blank. Updated my answer for this. –  Dominik Aug 19 at 12:50
    
Awesome ! It works perfectly ! Thank you very much ! :) –  Berhthun Aug 19 at 20:13

A solution using titletoc that's paired with titlesec. I added some letter spacing in chapter titles, with the microtype package, and changed the font to fourier and the last version of heuristica because Latin Modern doesn't have bold small caps (only ec, which isn't installed on my system):

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier, heuristica}

    \usepackage{microtype}
    \pretocmd{\lsstyle}{\SetTracking[no ligatures = {f}]{encoding = *}{50}}{}{}%
\usepackage{titlesec}
%\usepackage{shorttoc}
\usepackage{titletoc}
\usepackage{lipsum}

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

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

\renewcommand\thechapter{\arabic{chapter}}

% --------------------------------------------------
% Paramétrage des sections (chapitres)
% --------------------------------------------------
\titleclass{\section}{straight}
\titleformat{\section}[block]
    {\normalfont\huge\bfseries}
    {\textsc{Chapitre}~\thesection~:}
    {2.3ex plus.2ex}
    {\huge}

\titlespacing{\section}{0pt}{*1.5}{*3}

\renewcommand\thesection{\arabic{section}}

    \titlecontents{chapter}[1em]{\smallskip\bfseries}%\vspace{1cm}%
    {\contentslabel[\thecontentslabel]{1em}}%
    {\renewcommand\thecontentslabel{\relax}\itshape}%numberless%
    {,\mdseries\contentspage}[\medskip]%
    %
    \titlecontents{section}[4.25em]{\smallskip}%
    {\contentslabel[\thechapter.\thecontentslabel]{2em}}%numbered
    {\hspace*{-1em}}%numberless
    {\enspace\dotfill\contentspage}[\smallskip]%
    %


% --------------------------------------------------
% Document
% --------------------------------------------------

\begin{document}
    \chapter{Test chapter 1}
    \lipsum[1]
% \shorttableofcontents{Sommaire}{1}
    \chapter{Test chapter 2}
        \lipsum[1]
        \section{Test section 1}
        \lipsum[1]
    \tableofcontents
\end{document} 

enter image description here

share|improve this answer
    
Thank you for your answer, but I get "Chapitre 1 Test section 1" in my document and I would like no modification in the document while the table of contents and shorttoc display 2.1 Test section 1. –  Berhthun Aug 18 at 18:47
    
I don't understand very well: I didn't modify your code for chapter and section formatting, only added formatting instructions for the table of contents. What should be displayed in the document body exactly? Moreover using the words ‘partie’ in chapter headings and ‘chapitre’ in section headings is confusing. –  Bernard Aug 18 at 19:13
    
Sorry for the confusion, I edited my question and you can find a complementary explication. Sorry for my bad english, I'm not sure if I explain very well. :( –  Berhthun Aug 18 at 19:42
    
But that's what you have in the body with your code. And with my code for the toc, this particular example would give: 1. Hello World!, 1 for part-chapter 1, and 1.1 I'm a Robot .......... 2 for chapter-section 1. Or did I misunderstand? –  Bernard Aug 18 at 19:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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