layout
我正在用定义的顶部绘制一个网格geometry
。
\documentclass[letter]{article}
\usepackage{geometry}
\geometry{
showcrop,
paper = a4paper,
layout = a5paper,
layoutoffset={1cm,1cm}
}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}% just to generate text for the example
\makeatletter
% Code from:
% http://tex.stackexchange.com/questions/85064/grid-for-textpos-layout
\newcommand\rectangulargrid[2]{%
\tikz[
remember picture,
overlay,
yscale=-1,
xstep=\Gm@layoutwidth/#1,ystep=\Gm@layoutheight/#2,
xshift= -\Gm@layouthoffset, yshift=-\Gm@layoutvoffset,
]
\draw ($(current page.north west) - (\Gm@layouthoffset, \Gm@layoutvoffset)$) grid
($(current page.north west)+ (\Gm@layoutwidth, \Gm@layoutheight) + (\Gm@layoutwidth/#1, \Gm@layoutheight/#2) $);}
\makeatother
\begin{document}
\lipsum[1-3]
\rectangulargrid{16}{16}
\end{document}
我不知道为什么网格线与裁切标记不对齐。
有什么想法吗?
答案1
我自己画线也能达到同样的效果
\documentclass{article}
\usepackage{geometry}
\geometry{
showcrop,
paper = a4paper,
layout = a5paper,
layoutoffset={1cm,1cm}
}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}% just to generate text for the example
\makeatletter
\newcommand\rectangulargrid[2]{%
\begin{tikzpicture}[
remember picture,
overlay,
yscale=-1,
]
\draw[fill=red] ($(current page.north west)
+ (\Gm@layouthoffset, \Gm@layoutvoffset)
$)
circle (5pt);
\draw ($(current page.north west)
+ (\Gm@layouthoffset, \Gm@layoutvoffset)
$) -- + (0,-3cm);
\draw ($(current page.north west)
+ (\Gm@layouthoffset, \Gm@layoutvoffset)
$) -- + (-3cm,0);
\foreach \x in {0,...,#1}
{
\draw
($
(current page.north west)
+ (\Gm@layouthoffset, \Gm@layoutvoffset)
+ \x*(\Gm@layoutwidth/#1, 0)
$)
-- +(0,\Gm@layoutheight);
}
\foreach \y in {0,...,#2}
{
\draw
($
(current page.north west)
+ (\Gm@layouthoffset, \Gm@layoutvoffset)
+ \y*(0,\Gm@layoutheight/#2)
$)
-- +(\Gm@layoutwidth, 0);
}
\end{tikzpicture}
}
\makeatother
\begin{document}
\lipsum[1-3]
\rectangulargrid{16}{16}
\end{document}