2

I am trying to display Chinese character in watermark, here is the code.

\documentclass{article}
\usepackage{xeCJK}
\usepackage[printwatermark]{xwatermark}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{lipsum}

\newsavebox\mybox
\savebox\mybox{\tikz[color=red,opacity=0.3]\node{Chinese watermark 前言};}
\newwatermark*[
  allpages,
  angle=45,
  scale=6,
  xpos=-20,
  ypos=15
]{\usebox\mybox}

\begin{document}

this is Chinese 前言

\end{document}

both the Chinese characters in document and the English part in watermark renders correctly although the Chinese part in watermark is missing.

I run the code above on overleaf and got 2 warnings.

this one

Package xeCJK Warning: Fandol is being set as the default font for CJK text. Please make sure it has been properly installed.

and this one

Package fontspec Warning: Font "FandolSong-Regular" does not contain requested Script "CJK".

what am I missing?

1 Answer 1

2

Save the box in the document body. The fonts aren't completly setup in the preamble:

\documentclass{article}
\usepackage{xeCJK}
\usepackage[printwatermark]{xwatermark}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{lipsum}

\newsavebox\mybox
\newwatermark*[
  allpages,
  angle=45,
  scale=6,
  xpos=-20,
  ypos=15
]{\usebox\mybox}

\begin{document}
\savebox\mybox{\tikz[color=red,opacity=0.3]\node{Chinese watermark 前言};}

this is Chinese 前言

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .