Draftwatermark 包不需要的字体更改

Draftwatermark 包不需要的字体更改

我正在使用该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 例程的背景层(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}

相关内容