
我想創建一些內部有不止一種顏色的頭規則。問題是我在日誌中收到以下警告:
pdfTeX 警告:pdflatex:彈出空彩色頁面堆疊 0
我的文件的第二頁列印的是倒數第二個用於頭規的顏色。另一個問題是第二頁中的 rhead 填入了不需要的值。
我可以找到一種處理方法(通過在\normalcolor
每個之前添加並添加),但我擔心當我的文檔更加完整時會遇到其他問題(因為錯誤仍然存在,只有輸出被修復) 。\color
\renewcommand\headrule
\rhead{}
我對此進行了大量搜索,但沒有什麼真正有用的。
在這種情況下如何正確管理顏色堆疊?
這是使用的程式碼:
\documentclass{article}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath ,amsthm ,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{eso-pic}
\usepackage{xcolor}
\definecolor{logoColor}{RGB}{237,162,153}
\setlength\oddsidemargin{-0.5in}% marge de gauche (référence 0 est à 1 inche)
\setlength\topmargin{-0.75in}%espace blanc au dessus du header (référence 0 est à 1 inche)
\setlength\headheight{33pt}%see in a log, to avoid further problem in some cases
\setlength\headsep{1in}
\pagestyle{fancy}
\renewcommand\headrule{
\color{logoColor}
\vspace{1pt}
\hrule height 2pt width\headwidth
\vspace{1pt}
\color{blue}
\hrule height 1pt width\headwidth
}
\chead{ref:0214-07}
\begin{document}
This is some preamble text that you enter yourself.
\section{Text for the first section}
\lipsum[1]
\subsection{Text for a subsection of the first section}
\lipsum[2-3]
\part{test}
\subsection{Another subsection of the first section}
\lipsum[4-5]
\section{The second section}
\lipsum[6]
\subsection{Title of the first subsection of the second section}
\lipsum[7]
\end{document}
答案1
直接使用\color
很棘手,因為它會全域改變連續的顏色。最好在更改\begingroup...\endgroup
周圍使用一對\color
,在這種情況下,在重新定義的\headrule
命令中。這會刪除錯誤訊息並且應該是故障安全的。文件的全域顏色堆疊隨後不會更改。
\documentclass{article}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath ,amsthm ,amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{eso-pic}
\usepackage{xcolor}
\definecolor{logoColor}{RGB}{237,162,153}
\setlength\oddsidemargin{-0.5in}% marge de gauche (référence 0 est à 1 inche)
\setlength\topmargin{-0.75in}%espace blanc au dessus du header (référence 0 est à 1 inche)
\setlength\headheight{33pt}%see in a log, to avoid further problem in some cases
\setlength\headsep{1in}
\pagestyle{fancy}
\renewcommand\headrule{%
\begingroup
\color{logoColor}
\vspace{1pt}
\hrule height 2pt width\headwidth
\vspace{1pt}
\color{blue}
\hrule height 1pt width\headwidth
\endgroup
}
\chead{ref:0214-07}
\begin{document}
This is some preamble text that you enter yourself.
\section{Text for the first section}
\lipsum[1]
\subsection{Text for a subsection of the first section}
\lipsum[2-3]
\part{test}
\subsection{Another subsection of the first section}
\lipsum[4-5]
\section{The second section}
\lipsum[6]
\subsection{Title of the first subsection of the second section}
\lipsum[7]
\end{document}