5

It is similar to this question, but both of its answer do not seem to work here.

I defined the title format as follows:

\usepackage[explicit]{titlesec}
\titleclass{\part}{top} % make part like a chapter
\titleformat{\part}[display]
    {\raggedleft}
    {\MakeUppercase{\partname}~\thepart}
    {1em}
    {\MakeUppercase{#1}}
\usepackage[english,french]{babel}

Thus, ideally, one should see PARTIE I in a new part. But actually one would see Première partie I.

The method in the accepted answer does not have effect to this. On the other hand, with the following babel setting,

\frenchsetup{PartNameFull=false}

The result would become Partie I, still not in uppercase.

How can I fix this behavior? Or is there some way to just show Première partie without the I in French mode?

Below is a MWE.

\documentclass{article}

\usepackage[explicit]{titlesec}
\titleclass{\part}{top} % make part like a chapter
\titleformat{\part}[display]
    {\raggedleft}
    {\MakeUppercase{\partname}~\thepart}
    {1em}
    {\MakeUppercase{#1}}

\usepackage[english,french]{babel}

%% This produces "Partie"
% \frenchsetup{PartNameFull=false}%

%% These seem to have no effect
% \usepackage{etoolbox}
% \makeatletter
% \renewcommand\FB@emptypart{\def\thepart{\unskip}}
% \patchcmd{\@part}{\partname}{Partie}{}{}
% \makeatother

\begin{document}

\selectlanguage{french}
\part{Test}

\selectlanguage{english}
\part{Test}

\end{document}

ADD: I should mention that polyglossia doesn't have this problem, but on the other hand, one cannot get things like Première partie by its newly offered option frenchpart=true without any effort --- a "patch failure" is reported.

2 Answers 2

6

The french babel support tries to ensue that constructs like \partname~\thepart automatically get translated into "Première partie" by (locally) changing \thepart to suppress the number. This fails in your example because the \MakeUppercase make the local redefinition end before \thepart gets invoked. This can be avoided by moving \thepart into it's argument and protecting it:

Change {\MakeUppercase{\partname}~\thepart} to {\MakeUppercase{\partname~\protect\thepart}} to get "Première partie".

You can also locally redefine \frenchpartname to ensure that it works with \MakeUppercase:

Change

{\MakeUppercase{\partname}~\thepart}

to

{\renewcommand\frenchpartname{Partie}\MakeUppercase{\partname}~\thepart}

to get "PARTIE I".

6

The command \partname is defined to do complicated things that in your case are not needed.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[english,french]{babel}

\usepackage{titlesec}

\titleclass{\part}{top} % make part like a chapter
\titleformat{\part}[display]
    {\filleft}
    {\MakeUppercase{\partname}~\thepart}
    {1em}
    {\MakeUppercase}
\addto\captionsfrench{\renewcommand{\partname}{Partie}}

\begin{document}

%\selectlanguage{french} % French is already default
\part{Test}

\selectlanguage{english}
\part{Test}

\end{document}

enter image description here

A couple of notes: titlesec prefers \filleft to \raggedleft. There's no need to use explicit: the last token in the final mandatory argument to \titleformat is eventually followed by the braced title, so it can be a one-argument macro.

Actually, I usually discourage using explicit: better defining a separate macro that does what we want rather than clutter the argument to \titleformat with code.

2
  • In fact, the use of option explicit is because of my wish to separately define the numberless case, so that the part title is on the same vertical position comparing with the ones with numbers. Do you think there's a better way to achieve this?
    – Jinwen
    Feb 7, 2021 at 13:17
  • @Jinwen Nothing prevents you to use different macros in the final argument to \titleformat for the numbered and the numberless versions.
    – egreg
    Feb 7, 2021 at 13:19

You must log in to answer this question.

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