
複数の色を含むヘッドルールをいくつか作成したいと思います。問題は、ログに次の警告が表示されることです。
pdfTeX 警告: pdflatex: 空のカラー ページ スタック 0 をポップします
ドキュメントの 2 ページ目は、見出しルールに使用されている最後から 2 番目の色で印刷されます。もう 1 つの問題は、2 ページ目の見出しに望ましくない値が入力されることです。
処理する方法は見つかります (の\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}