안녕하세요!!헤더를 만들었으나 배경색을 설정할 수 없습니다. 저는 라텍스를 처음 접했고 매우 어렵다고 생각합니다. 누구든지 나를 도와주실 수 있나요??
내 작업은 다음과 같습니다.
\documentclass[14pt,a4paper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{titlesec, color}
\usepackage{theorem}
\newtheorem{worked example}{Worked Example}[chapter]
\newtheorem{solution}{SOLUSION}[chapter]
\usepackage{anyfontsize}
\usepackage{amsfonts}
\usepackage{textcomp}
\usepackage{enumerate}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\chaptermark}[1]{\markboth{\textbf{\thechapter \ | \ #1}}{}}
\fancyhead[LE]{\hspace{30pt}\textbf{\thepage} \hspace{20pt} \leftmark}
\renewcommand{\sectionmark}[1]{\markright{\textbf{\thesection \ | \ #1}}}
\fancyhead[RO]{\rightmark \hspace{20pt} \textbf{\thepage} \hspace{30pt}}
\fancyfoot{}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\renewcommand{\headrulewidth}{}
\renewcommand{\footrulewidth}{}
\setlength\headheight{50pt}
\newcommand{\hsp}{\hspace{20pt}}
\newcommand{\ntl}{\newline \newline}
\titleformat{\chapter}[hang]{\fontsize{50}{60}\bfseries\color[rgb]{0,0.5,0.75}}{\thechapter\hsp\fontsize{90}{60}\selectfont\textcolor{black}{|}\hsp}{0pt}{\Huge\bfseries}
\titleformat{\section}{\large\bfseries}{}{0pt}{\textcolor[rgb]{0,0.5,0.75}{Topic \thesection} \ }[{\titlerule[0.8pt]}]
\begin{document}
\chapter{\textcolor{black}{NUMBER}}
\section{BIDMAS.}
\thispagestyle{empty}
.
.
.
.
.
\end{document}
답변1
titleps
다음은 대신에 옵션을 사용하여 fancyhdr
로드하는 솔루션입니다 . 표시 문제로 싸울 필요가 없습니다. 새 페이지 스타일을 정의할 때 및를 사용하면 됩니다. 에 통합될 수 있으므로 새 장마다 입력하는 시간이 절약됩니다.titlesec
pagestyles
\sectiontitle
\chaptertitle
\thispagestyle{empty}
\titleformat[\chapter}
\documentclass[14pt,a4paper,twoside]{extbook}
\usepackage[utf8]{inputenc} %
\usepackage[T1]{fontenc}
\usepackage{lmodern} %
\usepackage[pagestyles]{titlesec}
\usepackage[x11names]{xcolor} %
\usepackage{theorem}
\newtheorem{worked example}{Worked Example}[chapter]
\newtheorem{solution}{SOLUTION}[chapter]
%\usepackage{anyfontsize}
\usepackage{amsfonts}
\usepackage{textcomp}
\usepackage{enumerate}
\setlength\headheight{21pt}
\newcommand{\hsp}{\hspace{20pt}}
\newcommand{\ntl}{\newline \newline}
\titleformat{\chapter}[hang]{\fontsize{50}{60}\bfseries\color[rgb]{0,0.5,0.75}}{\thechapter\hsp\fontsize{90}{60}\selectfont\textcolor{black}{|}\hsp}{0pt}{\thispagestyle{empty}\Huge\bfseries}
\titleformat{\section}{\large\bfseries}{}{0pt}{\textcolor[rgb]{0,0.5,0.75}{Topic \thesection} \ }[{\titlerule[0.8pt]}]
\usepackage{blindtext}
\newpagestyle{mine}{%
\setlength\fboxsep{10pt}
\sethead[\bfseries\llap{\colorbox{SteelBlue3}{\parbox{\dimexpr\marginparsep + \marginparwidth\relax}{\hspace{20pt}\color{white}\thepage\vphantom{|}}}}%
\colorbox{SlateGray2!40}{\parbox{\dimexpr\linewidth-2\fboxsep}{~\thechapter~|\hspace{0.75em}\chaptertitle}}][][]%
{}{}{\bfseries\colorbox{SlateGray2!40}{\parbox{\dimexpr\linewidth-2\fboxsep}{\thesection~|\hspace{0.75em}\sectiontitle}}%
\rlap{\colorbox{SteelBlue3}{\parbox{\dimexpr\marginparsep + \marginparwidth\relax}{\hspace{20pt}\color{white}\thepage\vphantom{|}}}}}
\setfoot{}{}{}
}
\pagestyle{mine}
\begin{document}
\chapter{{NUMBER}}%\textcolor{black}
\section{BIDMAS.}
\blindtext[10]
\end{document}
답변2
\headrulewidth
\footrulewidth
길이를 포함해야 하는 매크로입니다 . 0pt
규칙을 사라지게 하는 데 사용됩니다.
\renewcommand*{\headrulewidth}{0pt}
\renewcommand*{\footrulewidth}{0pt}
그런 다음 예제에서는 \colorbox
예제 코드( 로 컴파일됨 pdflatex
)를 보여줍니다.
\documentclass[a4paper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{color}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\chaptermark}[1]{%
\markboth{\textbf{\thechapter \ | \ #1}}{}%
}
\fancyhead[LE]{%
\hspace{30pt}\textbf{\thepage} \hspace{20pt} %
\colorbox[rgb]{0,0.5,0.75}{\leftmark}%
}
\renewcommand{\sectionmark}[1]{%
\markright{\textbf{\thesection \ | \ #1}}%
}
\fancyhead[RO]{%
\rightmark \hspace{20pt} \textbf{\thepage} \hspace{30pt}%
}
\fancyfoot{}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength\headheight{50pt}
\begin{document}
\chapter{\textcolor{black}{NUMBER}}
\section{BIDMAS.}
\thispagestyle{empty}
\newpage
Foo.
\newpage
Bar.
\end{document}