1

I've got this grid that I create using tikz (the actual code does more stuff, this is just an MWE). I'd like to print it two-sided such that, if you look at the sheet with a backlight, the lines would align. In other words, corners of the grid on front and back would be right on top one another. Is this possible?

Edit: I'm using XeLateX for this, if that is important

MWE:

\documentclass{article}

\usepackage[a4paper,
left=.5cm,
right=.5cm,
top=.5cm,
bottom=.5cm,
footskip=0cm]{geometry}

\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\tikzset{cross/.style={cross out, draw=gray, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt, dashed},
    %default radius will be 1pt. 
    cross/.default={1pt}}

\pagestyle{empty}

\newcounter{col}
\newcounter{row}

\newcommand\grid[4]{%
    \def\colnames{#1}%
    \def\size{#2}%
    \def\sep{#3}%
    \def\empties{#4}%
    \begin{tikzpicture}[yscale=-1]
    \pgfmathsetmacro{\inc}{\size+\sep}
    \setcounter{col}{0}
    \setcounter{row}{0}
    \foreach \colname in \colnames{
        \addtocounter{col}{1}
        \setcounter{row}{0}
        \foreach \empt in \empties{
            \addtocounter{row}{1}
            \draw ({(\thecol-1)*\inc+\size*0.5 pt},{\therow*\size+\size*0.5})
            node[cross=\size*0.35,rotate=45,darkgray]{};
            \draw[black] ({(\thecol-1)*\inc pt},{\therow*\size})
            rectangle ++ (\size,\size);
        }
    }
    \end{tikzpicture}%
}

\begin{document}
    
\centering

\grid{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}{10mm}{0mm}{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
\newpage
\grid{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}{10mm}{0mm}{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

\end{document}

1 Answer 1

4

If you use the center of the page as (0,0), then it is just a matter of investing in a printer that can make alignment of significantly less than a line width.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}[remember picture, overlay, shift=(current page.center)]
\draw (-10,-13) grid (10,13);
\draw[dashed, dash pattern=on 1mm off 1mm on 1mm off 1mm on 1mm off 0mm, shift={(0.5,0.5)}] (-10.5,-13.5) grid (9.5,12.5);
\end{tikzpicture}
\newpage
\pagestyle{empty}
\begin{tikzpicture}[remember picture, overlay, shift=(current page.center)]
\draw (-10,-13) grid (10,13);
\draw[dashed, dash pattern=on 1mm off 1mm on 1mm off 1mm on 1mm off 0mm, shift={(0.5,0.5)}] (-10.5,-13.5) grid (9.5,12.5);
\end{tikzpicture}
\end{document}

Two pages with grid

2
  • Thanks, that's easier than mine... so I guess [remember picture, overlay, shift=(current page.center)] is the only setting that is necessary for the alignment. Can I use that with any tikzpicture to align front and back, then?
    – Zubo
    Nov 16, 2021 at 22:20
  • 1
    @Zubo: You can use that to make the coordinate (0,0) to be at the center of the page. (needs two compilations). This will automatically align pages with symmetrical contend. Nov 17, 2021 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.