하위 섹션 색상 수정 페이지 헤더 변경

하위 섹션 색상 수정 페이지 헤더 변경

내 문제는 다음과 같습니다. 대학 템플릿을 다시 만들려고 합니다.

article첫 번째 페이지의 머리글과 바닥글이 다른 페이지와 다른 문서를 만들었습니다 . 조금 더러워졌지만 작동합니다.

첫 번째 페이지의 헤더가 다른 페이지의 헤더보다 깁니다.

그런 다음 섹션, 하위 섹션의 색상을 변경하고 싶었습니다. 패키지를 사용하여 titlesec색상을 수정했는데 색상을 변경하면 section문제가 없지만 subsection색상을 변경하면 두 번째 및 다음 페이지의 헤더가 표시됩니다. 너무 커지는 경우(첫 페이지의 내용처럼)

문서가 켜져 있습니다.GitHub. 이고 을 article_template(를) 실행할 수 있습니다 my_document.tex.

최소 작업 예:

\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}

이것으로 작동합니다:

첫 번째 페이지: 첫 페이지가 작동합니다.

두 번째 페이지와 다음은 다음과 같습니다. 두 번째 페이지는 괜찮습니다(하위 섹션은 검은색임).

참고로헤드/settings_esc_template.tex, 해당 행에 \titleformat*{\subsection}{\normalfont\large\bfseries\color{blue_title}}주석이 추가됩니다.

이제 줄의 주석 처리를 제거하여 하위 섹션(또는 하위 하위 섹션)을 파란색으로 넣으면 \titleformat*{\subsection}{\normalfont\large\bfseries\color{blue_title}}두 번째 페이지의 제목이 변경됩니다.

두 번째 페이지에 잘못된 헤더가 있습니다(파란색 하위 섹션).

동작은 패키지와 동일합니다 sectsty.

이 행동에 대한 설명이 있는 사람이 있나요?

도움을 주셔서 감사합니다(그리고 영어 실수로 인해 죄송합니다)!

답변1

복잡한 형상 재설정을 수행할 필요가 없습니다. 간단히 \vspace 및 \enlargethispage를 사용하여 이미지 높이를 부수어 페이지에 붙을 수 있도록 하세요.

\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}

관련 정보