我正在使用該draftwatermark
包和包含各部分的文檔verbatim
。這是一種常見/不需要的結果,其中當前頁面(或下一頁)格式會影響DRAFT
頁面上標記的字體。
如何控製字體?
最小工作範例:
\documentclass{article}
\usepackage{draftwatermark}
\usepackage{lipsum}
\begin{document}
\lipsum[1-10]
\begin{verbatim}
{
"aaaaaaaa": {
"aaaa": "aaaaaa",
"aaaa": "aaaaaaa",
"aa": 000,
"aaaaaa_aa": 0,
"aaaaaaaa_aaaaaa": [
{
"aaaa": "aaaaaa",
"aaaaaaa_aa": "aaaaaaa_aaaaaaa"
}
]
}
},
{
"aaaaaaaa": {
"aaaa": "aaaaaaaa",
"aaaa": "aaaaa",
"aa": 00000000,
"aaaaaa_aa": 000,
"aaaaaaaa_aaaaaa": [
{
"aaaa": "aaaaaaaa",
"aaaaaaa_aa": "aaaaa_aa_aaaa"
}
]
}
},
{
"aaaaaaaa": {
"aaaa": "aaaaaaa",
"aaaa": "aaaa",
"aa": 00000000,
"aaaaaa_aa": 00000000,
"aaaaaaaa_aaaaaa": [
{
"aaaa": "aaaaaaa",
"aaaaaaa_aa": "aaaa_aa_aaaa"
}
]
}
},
{
"aaaaaaaa": {
"aaaa": "aaaaaa",
"aaaa": "aaaaaaa",
"aa": 000,
"aaaaaa_aa": 0,
"aaaaaaaa_aaaaaa": [
{
"aaaa": "aaaaaa",
"aaaaaaa_aa": "aaaaaaa_aaaaaaa"
}
]
}
},
{
"aaaaaaaa": {
"aaaa": "aaaaaa",
"aaaa": "aaaa",
"aa": 00000000,
"aaaaaa_aa": 000,
"aaaaaaaa_aaaaaa": [
{
"aaaa": "aaaaaa",
"aaaaaaa_aa": "aaaa_aa_aaaa"
}
]
}
}
\end{verbatim}
\end{document}
答案1
您在這裡有幾個選擇。到目前為止,最簡單的方法是“重置”文字以包括\normalfont
:
\SetWatermarkText{{\normalfont DRAFT}}
或者,您可以刪除什麼draftwatermark
插入出貨例程的背景圖層 ( shipout/background
) 並重新插入包含以下內容的內容\normalfont
:
\makeatletter
\RemoveFromHook{shipout/background}[draftwatermark]% Remove default watermark
\AddToHook{shipout/background}[draftwatermark]{%
{\normalfont\draftwatermark@print{\draftwatermark@markcmd}}%
}
\makeatother
這裡用一個最小的例子展示了前一種方法:
\documentclass{article}
\usepackage{draftwatermark}
\usepackage{lipsum}
\SetWatermarkText{{\normalfont DRAFT}}% Avoid font changes across page boundaries that has font changes
\begin{document}
\lipsum[1-10]
\ttfamily% Switch to a different font family
\lipsum[1-5]
\end{document}