0

I am trying to format my \section command in order to get a result like :

enter image description here

"Partie" is a piece a text I want to see everytime. Then "1" corresponds to the section number, and "Introduction" to the section title.

I have found two differents things :

  • A way to draw a line under "Partie 1" :
\usetikzlibrary{calc}
\begin{center}
\begin{tikzpicture}[my node/.style={anchor=base,inner sep=0pt}]
\node[my node] (center) {Partie \thesection};
\draw($(center.base)+(-1.9cm,-1ex)$)     -- ($(center.base)+(+1.9cm,-1ex)$);
\end{tikzpicture}
\end{center}
  • A way to change the format of \section :
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\scshape}}
\makeatother

But I don't know how to mix those two ideas !

I'm using {book} documentclass. Even though it looks like "Partie 1 Introduction" is on a full page, it is not supposed to be the case. It is only a centred \section title with a line under.

Thank you all in advance !

4
  • 1
    Most LaTeX classes know a command called \part that may already be closer to what you want than \section.
    – moewe
    Apr 3 '20 at 13:46
  • 1
    Which documentclass do you use? Should "Partie 1 Introduction" occupy a page on its own? If so, you might be interested in modifying the \part command instead.
    – leandriis
    Apr 3 '20 at 13:46
  • Hi everyone ! Im using \documentclass[12pt,twoside,draft]{book} Unfortunately I am already using \part and \chapter. But "Partie 1 Introduction" is not supposed to use a full page !
    – Guliup
    Apr 3 '20 at 13:52
  • I am editing my post in order to add the documentclass I'm using and the fact that it is not supposed to use a full page.
    – Guliup
    Apr 3 '20 at 13:53
0

Welcome to TeX.SE...

Do you really this head belongs as \section, not sure. Anyhow, hope the below MWE may helps you...

\documentclass{book}
\usepackage{titlesec}

\begin{document}
\titleformat{\section}[block]
{\normalfont\bfseries\filcenter}{\textsc{Partie}\ \thesection\\\rule{\textwidth}{0.5pt}}{1em}{}

\section{Test}

\end{document}

Update

\titleformat{\section}[block]
{\normalfont\bfseries\filcenter}{\textsc{Partie}\
\thesection\\\rule{3cm}{0.5pt}\\}{1em}{}
8
  • 1
    Thank you for your answer ! It is almost perfect : the line has to be 3cm wide : when I change "\textwidth" by "3cm", the line and "Introduction" are side to side... Any idea ?
    – Guliup
    Apr 3 '20 at 14:00
  • @Guliup Check the Update suggestion...
    – MadyYuvi
    Apr 3 '20 at 14:05
  • 1
    Thats perfect !
    – Guliup
    Apr 3 '20 at 14:23
  • @Guliup Glad to help you, if the suggestion suits with your requirement, then please accept the answer by clicking the tick mark...
    – MadyYuvi
    Apr 3 '20 at 14:28
  • 1
    You are the best :)
    – Guliup
    Apr 3 '20 at 15:11

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.