Skip to main content
added 1171 characters in body
Source Link
nidarfp
  • 8.2k
  • 1
  • 22
  • 31

Here is a proposal:

% Source - https://tex.stackexchange.com/q/761440
% Posted by PHL, modified by community. See post 'Timeline' for change history
% Retrieved 2026-03-31, License - CC BY-SA 4.0

%!TEX TS-program = lualatex
\documentclass[a4paper]{article}
%\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry}
\usepackage{luadraw}
\usepackage{eso-pic}
\usepackage{lipsum}

\begin{luacode*}
local g = graph:new{
    margins={0,0,0,0}
    , size={18,18} 
    }
g:Linecolor("lightgray")
for j= 1, 5 do
    for k=1,10*j do
        g:Dcircle(Zp(j,k*math.pi/(5*j)),1)
    end
end
g:Savetofile("mybackground.tkz")
\end{luacode*}

\AddToShipoutPictureBG{%
\AtPageCenter{%
        \put(-9cm,-9cm){\input{mybackground.tkz}}% 9cm = half width and half height of the picture
    }}
\begin{document}

\lipsum[1-2]
\newpage
\lipsum[1-2]

\end{document}

enter image description here

EDIT Here is a second version that takes into account samcarter's comment. Furthermore, in this second version, the background is redrawn on each page and can therefore be modified (in the first version the background was static).

% Source - https://tex.stackexchange.com/q/761440
% Posted by PHL, modified by community. See post 'Timeline' for change history
% Retrieved 2026-03-31, License - CC BY-SA 4.0

%!TEX TS-program = lualatex
\documentclass[a4paper]{article}
%\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry}
\usepackage{luadraw}
\usepackage{lipsum}

\begin{luacode*}
function background()
    local g = graph:new{
        margins={0,0,0,0}
        , size={18,18} 
        }
    g:Linecolor("lightgray")
    for j= 1, 5 do
        for k=1,10*j do
            g:Dcircle(Zp(j,k*math.pi/(5*j)),1)
        end
    end
    g:Sendtotex()
end
\end{luacode*}
\def\background{\directlua{background()}}%

\AddToHook{shipout/background}
{%
    \put(\paperwidth/2-9cm,-\paperheight/2-9cm){\background}%
}    

\begin{document}

\lipsum[1-2]
\newpage
\lipsum[1-2]

\end{document}

The result is the same.

Here is a proposal:

% Source - https://tex.stackexchange.com/q/761440
% Posted by PHL, modified by community. See post 'Timeline' for change history
% Retrieved 2026-03-31, License - CC BY-SA 4.0

%!TEX TS-program = lualatex
\documentclass[a4paper]{article}
%\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry}
\usepackage{luadraw}
\usepackage{eso-pic}
\usepackage{lipsum}

\begin{luacode*}
local g = graph:new{
    margins={0,0,0,0}
    , size={18,18} 
    }
g:Linecolor("lightgray")
for j= 1, 5 do
    for k=1,10*j do
        g:Dcircle(Zp(j,k*math.pi/(5*j)),1)
    end
end
g:Savetofile("mybackground.tkz")
\end{luacode*}

\AddToShipoutPictureBG{%
\AtPageCenter{%
        \put(-9cm,-9cm){\input{mybackground.tkz}}% 9cm = half width and half height of the picture
    }}
\begin{document}

\lipsum[1-2]
\newpage
\lipsum[1-2]

\end{document}

enter image description here

Here is a proposal:

% Source - https://tex.stackexchange.com/q/761440
% Posted by PHL, modified by community. See post 'Timeline' for change history
% Retrieved 2026-03-31, License - CC BY-SA 4.0

%!TEX TS-program = lualatex
\documentclass[a4paper]{article}
%\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry}
\usepackage{luadraw}
\usepackage{eso-pic}
\usepackage{lipsum}

\begin{luacode*}
local g = graph:new{
    margins={0,0,0,0}
    , size={18,18} 
    }
g:Linecolor("lightgray")
for j= 1, 5 do
    for k=1,10*j do
        g:Dcircle(Zp(j,k*math.pi/(5*j)),1)
    end
end
g:Savetofile("mybackground.tkz")
\end{luacode*}

\AddToShipoutPictureBG{%
\AtPageCenter{%
        \put(-9cm,-9cm){\input{mybackground.tkz}}% 9cm = half width and half height of the picture
    }}
\begin{document}

\lipsum[1-2]
\newpage
\lipsum[1-2]

\end{document}

enter image description here

EDIT Here is a second version that takes into account samcarter's comment. Furthermore, in this second version, the background is redrawn on each page and can therefore be modified (in the first version the background was static).

% Source - https://tex.stackexchange.com/q/761440
% Posted by PHL, modified by community. See post 'Timeline' for change history
% Retrieved 2026-03-31, License - CC BY-SA 4.0

%!TEX TS-program = lualatex
\documentclass[a4paper]{article}
%\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry}
\usepackage{luadraw}
\usepackage{lipsum}

\begin{luacode*}
function background()
    local g = graph:new{
        margins={0,0,0,0}
        , size={18,18} 
        }
    g:Linecolor("lightgray")
    for j= 1, 5 do
        for k=1,10*j do
            g:Dcircle(Zp(j,k*math.pi/(5*j)),1)
        end
    end
    g:Sendtotex()
end
\end{luacode*}
\def\background{\directlua{background()}}%

\AddToHook{shipout/background}
{%
    \put(\paperwidth/2-9cm,-\paperheight/2-9cm){\background}%
}    

\begin{document}

\lipsum[1-2]
\newpage
\lipsum[1-2]

\end{document}

The result is the same.

Source Link
nidarfp
  • 8.2k
  • 1
  • 22
  • 31

Here is a proposal:

% Source - https://tex.stackexchange.com/q/761440
% Posted by PHL, modified by community. See post 'Timeline' for change history
% Retrieved 2026-03-31, License - CC BY-SA 4.0

%!TEX TS-program = lualatex
\documentclass[a4paper]{article}
%\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry}
\usepackage{luadraw}
\usepackage{eso-pic}
\usepackage{lipsum}

\begin{luacode*}
local g = graph:new{
    margins={0,0,0,0}
    , size={18,18} 
    }
g:Linecolor("lightgray")
for j= 1, 5 do
    for k=1,10*j do
        g:Dcircle(Zp(j,k*math.pi/(5*j)),1)
    end
end
g:Savetofile("mybackground.tkz")
\end{luacode*}

\AddToShipoutPictureBG{%
\AtPageCenter{%
        \put(-9cm,-9cm){\input{mybackground.tkz}}% 9cm = half width and half height of the picture
    }}
\begin{document}

\lipsum[1-2]
\newpage
\lipsum[1-2]

\end{document}

enter image description here