I have the following setup which generate lined-paper background in a4paper (modified from texblog and answer from this site)
I would like to make this code more papersize independent.
The value "28" on for-loop works for this papersize (A4), but for other papersize or orientation (Landscape/Potrait), it need to be adjusted.
I'm guessing I can put \paperheight somewhere in the for-loop, but I don't know how to convert that value (which is in inch or cm) into (coordinate-unit) after \draw.
Or maybe doing arithmetic with page.north west
and page.south west
, if that even possible.
Yes I know, I could just modified them manually (changing value 28 to 38 in for-loop when working in a3paper), but I'm interested on more automatic solution.
In short: I have those many \usepackage{geometry}
commented in code, and would want to make a single \mygraphpaper
definition that works on them all.
Layout document that I want to achieve: No left/right margin, the same x
margin from top and bottom
\documentclass{article}
\usepackage{tikz}
%\usepackage[landscape,a3paper]{geometry}
\usepackage[a4paper]{geometry}
%\usepackage[landscape,a5paper]{geometry}
%\usepackage[a5paper]{geometry}
%\usepackage[landscape,paperheight=8.17in,paperwidth=6.32in,top=1in,bottom=1in,right=1in,left=1in]{geometry}
\usetikzlibrary{calc}
\def\mygraphpaper{%
\begin{tikzpicture}
\foreach \i in {4,5,...,28}{
\draw[gray] ($(current page.north west)+(0,-\i)$) -- ($(current page.north east)+(0,-\i)$);}
\end{tikzpicture}%
}
\usepackage{background}
\backgroundsetup{
angle=0,
contents=\mygraphpaper,
color=black,
scale=1,
}
\begin{document}
\pagenumbering{gobble}
$\,$
\end{document}