Sophanatprime / cus

CusTeX
8 stars 4 forks source link

`\background` 如何实现 `rm` 的位置? #54

Closed xkwxdyy closed 3 weeks ago

xkwxdyy commented 3 weeks ago

手册上:

水平位置包括:左(l)、右(r)、内侧(i)、外侧(o);垂直 位置包括:顶部(t)、底部(b);它们的组合也就是 layout 的四个角。此外 还有一个 cm,它表示 layout 的正中心,这也是默认值

我试了一下好像 lm rm 这种不行,为什么不把 cm 也放入可选中呢?

主要需求是想实现这样的 logo image

就是放在页面的左侧或者右侧,只出现一半。

xkwxdyy commented 3 weeks ago

我看手册后面提供了 tikz 的方法:

\background+(tikz)[./logo]{
  \node at (text.east) {\includegraphics[height = \textheight]{logo-black}};
}

这样可行,但是一旦加上了 \transparent{0.2}

\background+(tikz)[./logo]{
  % \put(6cm, -7cm){\transparent{0.2}\includegraphics[width = 5cm]{logo-black}}
  \node at (text.east) {\transparent{0.2}\includegraphics[height = \textheight]{logo-black}};
}

就报错

Package tikz: Giving up on this path. Did you forget a semicolon?.
Sophanatprime commented 3 weeks ago

加括号,或者直接用 text opacity=0.2,如果是 XeLaTeX 还需要 \DocumentMetadata{}

\background+(tikz)[./logo]{
  % \put(6cm, -7cm){\transparent{0.2}\includegraphics[width = 5cm]{logo-black}}
  \node at (text.east) {{\transparent{0.2}\includegraphics[height = \textheight]{logo-black}}};
}

另外,上面的代码,图片位置并不一定是你想要的位置。

xkwxdyy commented 3 weeks ago

加括号,或者直接用 text opacity=0.2,如果是 XeLaTeX 还需要 \DocumentMetadata{}

感谢!效果很好。

另外,上面的代码,图片位置并不一定是你想要的位置。

谢谢提醒,我对 anchor 加了一个 shift 调整就行

\node[text opacity = 0.05] at ([shift={(-10em,0em)}]text.east) {\includegraphics[height = \textheight]{logo-black}};

另外还有个延伸的问题,就是 cus 下奇偶不同水印的最佳方案是什么呢?我的想法是在 shiftout 的 hook 处判断 page 的奇偶,然后用不同的 \background。不过这个 cus 能否将其打包成一个命令,就是奇偶页的 \foreground\background

Sophanatprime commented 3 weeks ago

直接用 \ifodd\c@page 判断就可以了,它们总是能获得正确的值。

\def\oddbackground{..}
\def\evenbackground{..}
\background{\ifodd\c@page \oddbackground\else \evenbackground\fi}
xkwxdyy commented 3 weeks ago

直接用 \ifodd\c@page 判断就可以了,它们总是能获得正确的值。

好的,感谢