mcnees / LaTeX-Graph-Paper

Make your own quadrille, graph, hex, etc paper! Uses the pgf/TikZ package for LaTeX, which should be part of any modern TeX installation.
Other
456 stars 46 forks source link

Figure out how to properly shift lightcone pattern #10

Open duetosymmetry opened 3 years ago

duetosymmetry commented 3 years ago

The current myshift code doesn't do what it's supposed to (try using lightcone with user-selected margins)

duetosymmetry commented 3 years ago

Here's what I've learned in experimenting a little bit. On letterpaper, all the shifting works as intended (the lower-left corner of the pattern lines up). On a4paper, the pattern is shifted by how much myshift=... is set in the pattern code. However, there is a constant relative offset between the phase of the pattern and the lower-left corner of the page. So, our shifting code is not at fault — I think there is some shifting issue inside of pgf that's messed up for different page sizes.

mcnees commented 3 years ago

If I replace tile transformation={ shift=\myshift, }, with tile transformation={ shift={(0,0)}, }, then it works for both letter and a4 paper.

duetosymmetry commented 3 years ago

Wait, really? I'm getting different offsets on a4paper when I use different vmargin= or hmargin= in geometry. That is, try compiling with this in grid-with-light-cones.tex:

\usepackage[pattern=lightcone, geometry={a4paper, hmargin=1.1cm}]{graphpaper}
mcnees commented 3 years ago

No, sorry, it doesn't work. I was only running the fullpage examples. It worked for those.

mcnees commented 3 years ago

Implementing the grid and the lightcones with the "Hatch" pattern seems to work for all the paper sizes and margins I've tried. Something like this:

\begin{tikzpicture}
       % Rotated hatch is the lightcones
    \draw[pattern={Hatch[distance={0.25in/sqrt(2)},angle=45,xshift=0in,yshift=0in]},pattern color=red!25] (0,0) rectangle (\textwidth,\textheight);
       % Regular hatch is the grid
    \draw[pattern={Hatch[distance=0.25in,xshift=0in,yshift=0in]},pattern color=blue!50] (0,0) rectangle (\textwidth,\textheight);
\end{tikzpicture}
mcnees commented 3 years ago

Hmm, maybe not. Once we use the [remember picture, overlay] option in the tikzpicture environment it all goes screwy.

tdwiser commented 3 years ago

I got things to line up by abandoning patterns entirely in #23 . @duetosymmetry mentioned the same shifting bug (maybe more an underspecification than a bug??) should affect all patterns including tri and iso. However, those patterns don't have to line up with any non-pattern lines (since all the lines are in the pattern; lightcone tries to align lines in a pattern fill with lines in a drawing). So I'm not sure if it's necessary to abandon patterns entirely; they seem to have a big advantage in PDF rendering speed as well as code simplicity.