丝带本身被无耻地偷走了这个答案:
\documentclass{scrbook}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\stripskip}{5}
\newcommand{\stripwidth}{3}
\begin{document}
\begin{tikzpicture}[
overlay,
remember picture,
legend/.style={|<->|, gray, font = {\ttfamily}},
confidential/.style={anchor=center, rotate = -45, font={\sffamily\scshape}}
]
\coordinate (A) at ($ (current page.north east) + (-\stripskip,0) $);
\coordinate (A') at ($(A) + (-\stripwidth,0) $);
\coordinate (B) at ($ (current page.north east) + (0,-\stripskip) $);
\coordinate (B') at ($(B) + (0,-\stripwidth) $);
\fill [red] (A) -- (A') -- (B') -- (B) -- cycle;
\coordinate (tempA) at ($(A)!.5!(A')$);
\coordinate (tempB) at ($(B)!.5!(B')$);
\node [confidential](text) at ($(tempA)!.5!(tempB)$) {Confidential};
\draw [legend] ($(A) + (0,-.75ex)$) -- ($(A') + (0,-.75ex)$) node [below, midway] {\textbackslash stripwidth};
\draw [legend] ($(A) + (0,-.75ex)$) -- ($(current page.north east) + (0,-.75ex)$) node [below, midway] {\textbackslash stripskip};
\end{tikzpicture}
\centering Lorem ipsum
\end{document}
我为这个简单的问题感到抱歉,但 TikZ 对我来说仍然是黑魔法。
答案1
您只需将坐标从 更改为current page.north.east
并current page.south east
正确添加距离\stripskip
....
\documentclass{scrbook}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcommand{\stripskip}{5}
\newcommand{\stripwidth}{3}
\begin{document}
\begin{tikzpicture}[
overlay,
remember picture,
legend/.style={|<->|, gray, font = {\ttfamily}},
confidential/.style={anchor=center, rotate = 45, % <-- changed angle
font={\sffamily\scshape}}
]
\coordinate (A) at ($ (current page.south east) + (-\stripskip,0) $);% <-- changed coordinate from 'north' to south'
\coordinate (A') at ($(A) + (-\stripwidth,0) $);
\coordinate (B) at ($ (current page.south east) + (0,\stripskip) $);% <-- changed coordinate from 'north' to south' and sign for \stripskip
\coordinate (B') at ($(B) + (0,\stripwidth) $);% <-- changed sign for \stripskip
\fill [red,semitransparent] (A) -- (A') -- (B') -- (B) -- cycle;
\coordinate (tempA) at ($(A)!.5!(A')$);
\coordinate (tempB) at ($(B)!.5!(B')$);
\node [confidential](text) at ($(tempA)!.5!(tempB)$) {Confidential};
\end{tikzpicture}
\lipsum[1]
\end{document}