1

I want to just place simple object on the corners of each page (and to be able to exclude some pages. I can even do it manually for each page as they are really few), with the usual notation:

\newpgfornamentfamily{pgfhan}
\pgfornament[width = 2cm, color = black!]{5}

or

\newpgfornamentfamily{pgfhan}
\begin{tikzpicture}
\tikzset{pgfornamentstyle/.style={
fill=black!,
fill opacity=1,
line width=0.1pt}}%
\pgfornament[color=black!,scale=0.45,anchor=south, symmetry=v]{5}%
\end{tikzpicture}

An example of working code:

\documentclass{article}
\usepackage{pgfornament}

\begin{document} \newpgfornamentfamily{pgfhan} \begin{tikzpicture} \tikzset{pgfornamentstyle/.style={ fill=black!, fill opacity=1, line width=0.1pt}}% \pgfornament[color=black!,scale=0.45,anchor=south]{5}% \end{tikzpicture}

\renewcommand{\contentsname}{ \begin{center} Contenuti \end{center}} \tableofcontents

\section{a} \end{document}

I read online a lot of stuff, but most are inside convolved examples I can't split in little parts and identify what I need.

Can you help me?

Matteo
  • 47
  • 5
  • 1
    please make all your code fragments complete (a minimal working example - MWE) including the document class you are using and ONLY the packages required to replicate your problem. I could also benefit from some drawing or sketch or what you want the result to looklike. Thanks – Mane32 Feb 26 '24 at 18:54
  • 1
    Most likely, you can just use \AddToHook{shipout/background} and place a tikzpicture at the background of the page. See: https://tex.stackexchange.com/q/642020/47927 – Jasper Habicht Feb 26 '24 at 19:01

1 Answers1

2

In case you want a fully working example, here is one. I assume you want each corner to have individual pgfornament. Define a new command \addpgfornaments contain code of drawing four pgfornaments on each corner. Use this command inside \AddToHook{shipout/background}{\addpgfornaments} to add drawing in each page and switch off the pgfornaments drawing on corresponding page using \RemoveFromHook{shipout/background} then switch back on using \AddToHook{shipout/background}{\addpgfornaments} again.

\documentclass{article}
\newcounter{loopcount}
\usepackage{pgfornament}
\newpgfornamentfamily{pgfhan}
\newcommand{\addpgfornaments}{\begin{tikzpicture}[
remember picture, 
overlay,
pgfornamentstyle/.style={scale=0.45}
]
\node [anchor=north west,inner sep=0pt] at (current page.north west) {\pgfornament {5}};
\node [anchor=south west,inner sep=0pt] at (current page.south west) {\pgfornament[symmetry=h] {5}};
\node [anchor=north east,inner sep=0pt] at (current page.north east) {\pgfornament[symmetry=v] {5}};
\node [anchor=south east,inner sep=0pt] at (current page.south east) {\pgfornament[symmetry=v,symmetry=h] {5}};
\end{tikzpicture}}
\AddToHook{shipout/background}{\addpgfornaments}
\begin{document}

\renewcommand{\contentsname}{ \begin{center} Contenuti \end{center}} \tableofcontents

\loop\ifnum\value{loopcount}<30 \stepcounter{loopcount} \addcontentsline{toc}{section}{testing}\repeat

\clearpage\RemoveFromHook{shipout/background} \section{a}\clearpage \section{b}\clearpage\AddToHook{shipout/background}{\addpgfornaments} \section{c} \end{document}

enter image description here enter image description here

Tom
  • 7,318
  • 4
  • 21