[Tex/LaTex] French quotation marks in titles

frenchpunctuation

I'm currently finishing my PhD thesis. I use Lyx and the packages

\usepackage[french]{babel}
\frenchbsetup{FrenchFootnotes=false}

I use the french quotation marks (guillemets) without any problem inside the text, but the french guillemets are replaced by english ones in the titles (chapters, sections…) when the document becomes a .pdf.

I'm sure there is a simple answer to that, but I didn't find it online.

Thanks a lot for your help!

Here is a compilable code:

\documentclass[12pt,oneside,english,french,oldfontcommands]{memoir}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[utf8]{luainputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{-2}
\setcounter{tocdepth}{5}
\setlength{\parindent}{1.15cm}
\setSpacing{1.3999999999999999}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\date{} 

\usepackage[french]{babel}
\usepackage{csquotes}
\frenchbsetup{FrenchFootnotes=false}
\setcounter{secnumdepth}{5}
\usepackage{chngcntr}
\counterwithout{paragraph}{subsubsection}
\renewcommand*{\theparagraph}{\arabic{paragraph}.}
\newcommand\p{\paragraph{}}

\newcommand\ap{\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}}
\newcommand\av{\addtocontents{toc}{\protect\setcounter{tocdepth}{4}}}


\usepackage[bottom]{footmisc}

\renewcommand\@makefntext[1]{%
  \noindent
\mbox{\@thefnmark.~}{#1}}
\makeatother

\let\footnotesize\scriptsize

\addtolength{\skip\footins}{4mm}

\makeatother

\usepackage{babel}
\makeatletter
\addto\extrasfrench{%
   \providecommand{\og}{\leavevmode\flqq~}%
   \providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}%
}

\makeatother
\begin{document}
Text \og inside \fg{} the text.


\paragraph*{1° â Text \og inside \fg{} the paragraph title}

\selectlanguage{english}%
\p{}\foreignlanguage{french}{Text \og following \fg{} the paragraph
title.}\selectlanguage{french}%

\end{document}

Best Answer

In run-in titles like \paragraph LaTeX sets the text of title at the time when the following paragraph starts. So the \selectlanguage{english} "backfires" (a \color{red} at this place would color the title too). So you should start the paragraph before changing the language, e.g. with \leavevmode:

\documentclass[12pt,oneside,english,french]{memoir}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{babel}
\usepackage{csquotes}

\begin{document}
Text \og inside \fg{} the text.

\paragraph*{Text \og inside \fg{} title}

\selectlanguage{english} \og blb\fg{}

\selectlanguage{french}

\paragraph*{Text \og inside \fg{} title}

\leavevmode\selectlanguage{english} \og blb\fg{}
\end{document}

enter image description here