設定頁碼格式

設定頁碼格式

我試圖將我的作業文件中的頁碼作為分數。但是,當我嘗試以不同的顏色顯示分數時,最後一頁不會改變其顏色。如何確保整個部分都是綠色的,而不僅僅是當前頁面?

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{xcolor}

\definecolor{myGreen}{rgb}{0,.4,0}

\fancyfoot[R]{\textcolor{myGreen}{\thepage/\pageref{LastPage}}}
\begin{document}
\lipsum[1-8]
\end{document}

在此輸入影像描述

答案1

您可能使用彩色鏈接,最後一頁的鏈接顏色會幹擾您為頁碼選擇的顏色。您可以像這樣停用連結顏色:

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}

\fancyfoot[R]{\textcolor{green}{\hypersetup{hidelinks}\thepage/\pageref{LastPage}}}
\pagestyle{fancy}
\begin{document}
\lipsum[1-8]
\end{document}

答案2

發布的程式碼根本不會產生小數頁碼,因為從未應用自訂頁腳。當我調整程式碼以應用頁腳時,我得到了一個統一顏色的分數。

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{xcolor}

\definecolor{myGreen}{rgb}{0,.4,0}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\textcolor{myGreen}{\thepage/\pageref{LastPage}}}
\begin{document}
\lipsum[1-8]
\end{document}

小數頁碼中的綠色分子與分母

請注意,您可能實際上並不需要lastpage此功能。然而,目前的文檔似乎有點混亂,所以lastpage如果它現在能完成工作,我會繼續使用。 (文件說內核中提供了等效的功能,但更高級的用途可能需要pageslts。然後它說pageslts與當前的 LaTeX 不相容。)

相關內容