Alterando a cor da subseção, modificando o cabeçalho da página

Alterando a cor da subseção, modificando o cabeçalho da página

Aqui está o meu problema: estou tentando recriar meu modelo de universidade.

Criei um articledocumento onde a primeira página tem cabeçalho e rodapé diferentes das outras páginas. Está um pouco sujo, mas funciona...

O cabeçalho da primeira página é mais longo que os das outras.

Aí eu queria mudar a cor das minhas seções, subseções... Usei o titlesecpacote para modificar a cor e quando mudo a sectioncor não tem problema, mas quando mudo a subsectioncor, meu cabeçalho na segunda e nas seguintes páginas ficar muito grande (como o da primeira página).

O documento está emGitHub. É o article_templatee você pode executar o my_document.tex.

O exemplo mínimo de trabalho:

\documentclass[a4paper,12pt]{article}

% French or english language
\usepackage[english,french]{babel}

% To write special caracters
% to be used with Linux/Windows
\usepackage[utf8]{inputenc}

% Set the fonts
% Palatino for rm and math | Helvetica for ss | Courier for tt
\usepackage{mathpazo} % math & rm
\usepackage[scaled]{helvet} % ss
\usepackage{courier} % tt
%\normalfont % the default
\usepackage[T1]{fontenc}
% to write the text in sans serif
\renewcommand\familydefault{\sfdefault}

% Set the spacing
\usepackage{setspace}
\onehalfspacing

\usepackage[dvipsnames]{xcolor}

\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\definecolor{blue_title}{RGB}{46,116,181}

\usepackage{titlesec}
\titleformat*{\section}{\normalfont\Large\bfseries\color{blue_title}}
%\titleformat*{\subsection}{\normalfont\large\bfseries\color{blue_title}}
%\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries\color{blue_title}}


% set the margin
% Taille des marges
\usepackage[top=2cm, bottom=4cm, left=2.5cm , right=2.5cm, includehead, showframe]{geometry}
%\usepackage{geometry}
%\geometry{bindingoffset=1cm} % to bind pages
\usepackage{afterpage}

% to be able to use landscape
\usepackage{lscape}

% To skip indent at the begining of paragraphs
\usepackage[parfill]{parskip}

% For quotes adapted in the
\usepackage{csquotes}

% for bullet points
\usepackage{enumitem}

% Footnote definition
\usepackage[hang, bottom]{footmisc}

%Pour le header
\usepackage{fancyhdr}

\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\pagestyle{fancy}
    \fancyhf{}
    \setlength\headheight{45pt}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \fancyhead[L]{\includegraphics[width=1.56in, height=0.55in]{example-image}}
    \fancyhead[R]{\thepage}

\fancypagestyle{my_style}{
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \fancyhead[L]{\includegraphics[width=5.5in, height=1in]{example-image}}
    \fancyfoot[C]{\includegraphics[width=6.7in, height=0.7in]{example-image}}
    }



\usepackage{graphicx}
\usepackage{lipsum}



\begin{document}
\selectlanguage{english}

\newgeometry{top=1.5cm, bottom=4cm, left=2.5cm , right=2.5cm, includehead}
\setlength\headheight{81pt}
\setlength\footskip{56pt}


\thispagestyle{my_style}
%\vspace*{0.5cm}
\Huge % size
\textbf{Magnificient Title}
%\rule{5cm}{0.2pt}

\large
\textcolor{gray}{
Subtitle --- \today
}

\setcounter{page}{1}
\afterpage{\aftergroup\restoregeometry}


\section*{Abstract}
\addcontentsline{toc}{section}{Abstract} % adds an entry to the table of contents
\lipsum[1-2]
\section{The First Section}
\subsection{With a sub secion}
\subsubsection*{and again}

\lipsum[1-10]
\end{document}

Com isso funciona:

A primeira página: A primeira página funciona

E a segunda página e seguintes: A segunda página está boa (a subseção está em preto)

Observe que nohead/settings_esc_template.tex, a linha \titleformat*{\subsection}{\normalfont\large\bfseries\color{blue_title}}é comentada.

Agora, se eu colocar a subseção (ou a subsubseção) em azul descomentando a linha \titleformat*{\subsection}{\normalfont\large\bfseries\color{blue_title}}, meu título na segunda página muda...

A segunda página tem um cabeçalho errado (subseção em azul)

O comportamento é o mesmo com o sectstypacote.

Alguém tem uma explicação para esse comportamento?

Obrigado pela sua ajuda (e desculpe pelos meus erros de inglês)!

Responder1

Não há necessidade de fazer redefinições complicadas da geometria. Basta usar \vspace e \enlargethispage e diminuir a altura das imagens para que elas possam aderir às páginas:

\documentclass[a4paper,12pt]{article}

\usepackage[english,french]{babel}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[parfill]{parskip}
\usepackage{setspace}
\onehalfspacing

\usepackage{xcolor}
\usepackage{titlesec}
\titleformat*{\section}{\normalfont\Large\bfseries\color{blue}}
\titleformat*{\subsection}{\normalfont\large\bfseries\color{blue}}
\titleformat*{\subsubsection}{\normalfont\normalsize\bfseries\color{blue}}

%page layout of second and following pages, adapt the values if needed
\usepackage[top=2cm, bottom=4cm, left=2.5cm , right=2.5cm, 
           includehead, headheight=45pt, showframe]{geometry}

\usepackage{fancyhdr}

\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\pagestyle{fancy}
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    \fancyhead[L]{\includegraphics[width=1.56in, height=0.55in]{example-image}}
    \fancyhead[R]{\thepage}

\fancypagestyle{my_style}{
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
    %raise the boxes and smash their height on page 1, adapt the values
    \fancyhead[L]{%
     \raisebox{-2cm}[0pt][0pt]{\includegraphics[width=5.5in, height=1in]{example-image}}}
    \fancyfoot[C]{%
     \raisebox{-0.5cm}[0pt][0pt]{\includegraphics[width=6.7in, height=0.7in]{example-image}}}
    }

\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}
\selectlanguage{english}

\thispagestyle{my_style}
\vspace*{0.5cm}  %adapt to move the text down
\enlargethispage{-1cm} %adapt to shorten the first page if needed
\Huge % size
\textbf{Magnificient Title}
%\rule{5cm}{0.2pt}

\large
\textcolor{gray}{Subtitle --- \today}

\section*{Abstract}
\addcontentsline{toc}{section}{Abstract} % adds an entry to the table of contents
\lipsum[1-2]
\section{The First Section}
\subsection{With a sub secion}
\subsubsection*{and again}

\lipsum[1-10]
\end{document}

informação relacionada