如何使用背景包在圖像上方繪製文字?

如何使用背景包在圖像上方繪製文字?

我正在努力將水印重複為這裡回答了。 使用這種方法,我發現繪製的背景總是出現在使用添加的圖像下方\includegraphics。採取以下文件:

\documentclass{scrartcl}
\usepackage{background}
\usepackage{lipsum}

\backgroundsetup{
  color=red,
  angle=45,
  opacity=.8,
  contents={\large{Hellow World}}
}

\begin{document}
\lipsum[1-2]
\begin{center}
\includegraphics[width=5cm]{wikimedia}
\end{center}
\lipsum[2]
\end{document}

渲染 PDF構造的有效,但添加的圖像始終顯示在頂部:帶有圖形破壞水印文字的渲染 PDF

有沒有辦法配置背景包或其他設置,以便Hello World下面的文字始終顯示在文件中所有內容的頂部?我確實意識到包的名稱暗示了相反的情況。

或者我應該投入更多時間來解決這個問題KOMA 腳本 scrlayer-scrpage或另一種選擇?

答案1

背景套件使用 everypage 套件,這個套件只是添加背景資料。

我個人更喜歡使用 eso-pic 套件(也是因為背景使用 tikzpicture 這使得在材質中使用它們變得困難)。但如果你想保留背景,你可以嘗試調整背景:

\documentclass{scrartcl}
\usepackage{background}
\usepackage{lipsum}
\usepackage{eso-pic}
\makeatletter
\let \AddEverypageHook \AddToShipoutPictureFG
\renewcommand\AddThispageHook{\AddToShipoutPictureFG*}
\ifbg@some
  \AddThispageHook{}
\else
  \AddEverypageHook{\bg@material}
\fi
\makeatother

\backgroundsetup{
  color=red,
  angle=45,
  opacity=.8,
  contents={\large{Hellow World}},
}

\begin{document}
\lipsum[1-2]
\begin{center}
\includegraphics[width=5cm]{example-image-duck}
\end{center}
\lipsum[2]
\end{document}

在此輸入影像描述

相關內容