
我想在我的乳膠文檔中的頁碼後面有一個圖像,並嘗試像這樣寫
\fancyhead[CE,CO]{\textcolor{white}{\thepage}}
\chead{\includegraphics[width=1cm]{img.eps}}
問題是:當我首先得到帶有頁碼的行,然後是圖像時,我只能得到圖像,如果我有相反的方法,那麼我只能得到數字。怎麼樣才能讓圖片前面有數字呢?我應該使用背景圖片嗎?
答案1
答案2
您可以按照您希望分層的順序設定內容。
考慮到上述情況,我們可以在L
eft 標頭中設定圖像,然後設定C
entred 標頭:
\documentclass{article}
\usepackage{graphicx,fancyhdr,xcolor,lipsum}
\fancyhead[C]{\textcolor{white}{\thepage}}
\fancyhead[L]{\makebox[\textwidth]{\includegraphics[height=.7\baselineskip]{example-image}}}
\pagestyle{fancy}
\begin{document}
\lipsum[1-10]
\end{document}
eft標頭設定在自然居中的L
寬度框中。\textwidth
可能需要調整影像的位置。
如果您想要的只是黑色背景上的白色頁碼,您可以使用
\fancyhead[C]{\raisebox{0pt}[0pt][0pt]{\colorbox{black}{\textcolor{white}{\thepage}}}}
它使用以下命令設定頁碼\colorbox
: