1

I am trying to change the aspect of \part titles. My goal is to reach this aspect :

enter image description here

Here is what I have done so far :

\documentclass[12pt,twoside,draft]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}

\usepackage[T1]{fontenc}
\usepackage{librecaslon}


\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{titlesec}

\renewcommand{\thepart}{\arabic{part}}

\newcommand\encadrement[1][1cm]{%
    \tikz[overlay,remember picture,line width=0.3pt]
    \draw(-8.2mm,5.1mm) -- (109.8mm,5.1mm);%
    \tikz[overlay,remember picture,line width=0.3pt]
    \draw(-8.2mm,5.1mm) -- (-8.2mm,-192.9mm);%
}

\makeatletter
\def\@part[#1]#2{%
\encadrement[1cm]
\thispagestyle{empty}
\ifnum \c@secnumdepth >\m@ne
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
{\parindent \z@ 
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >\m@ne
\begin{center}
\begin{tikzpicture}[my node/.style={anchor=base,inner sep=0pt}]
\node[my node] (center) {\text{Livre} \thepart};
\draw($(center.base)+(-1.9cm,-1ex)$)     -- ($(center.base)+(+1.9cm,-1ex)$);
\end{tikzpicture}
\end{center}

\par\nobreak
\fi
\huge \bfseries #2
\markboth{}{}\par}
\newpage
\@afterheading}
\makeatother

And here is the result :

enter image description here

As you can see, my \newpage move the title to the middle of the page. With a \pagebreak it goes to the bottom of the page. And without any command, it gets split between the first and the second page.

Does anyone have an idea how to solve this ?

And by the way, if someone can explain this piece of code, I would really appreciate !

\ifnum \c@secnumdepth >\m@ne
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
{\parindent \z@ 
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >\m@ne

Thanks a lot !

2 Answers 2

1

An answer to your auxiliary question concerning the code below

\ifnum \c@secnumdepth >\m@ne
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
{\parindent \z@ 
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >\m@ne

It checks if the value of the secnumdepth counter (which controls the numbering of sectional divisions) is 0 or more. If it is less than 0 it does not number the \part but if 0 or more it numbers the \part.

1
  • Thank you, very clear.
    – Guliup
    Apr 6, 2020 at 13:41
0

I have been able to solve this using the following code :

\newcommand\framethispage[1][1cm]{%
    \tikz[overlay,remember picture,line width=0.2pt]
    \draw([xshift=(#1),yshift=(-#1)]current page.north west) -- ([xshift=(#1),yshift=(#1)+2mm]current page.south west);%
    \tikz[overlay,remember picture,line width=0.2pt]
    \draw([xshift=(#1),yshift=(-#1)]current page.north west) -- ([xshift=(-#1)-2mm,yshift=(-#1)]current page.north east);%
}

And then adjusting the title position with \vspace.

You must log in to answer this question.

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