0

after Phelype has solved my problem concerning the poles of my grid I tried to make the next step. The grid should be available on every page and should not interact with the "normal" text in the body.

Package everypage works fine, but in the first attempt I was unable to position my grid with tikz. As far as I understood the documentation the main coffin poles [H,l] should have been in the same position as (current page.north west), but it was [hc,vc] instead. Probably I didn't read careful enough ... and had to calculate offsets as a workaround. Any better approach would be welcome.

On the second page I still find the coffins content of page 1 (of course), but how clearing it? I could not find a way except setting the coffin and its poles again (defined a command for that). I tried to put the init-command at the end of the everypage-hook, but this doesn't work, probably because shipout is not finished. On the other hand I also didn't get the afterpage-hook work. So again, any better approaches would be welcome. Thanks, Jens.

\documentclass[a4paper,twoside,10pt]{scrbook}%

\setlength{\parindent}{0mm}%
\pagestyle{empty}%
\usepackage[width=176mm,height=236mm,left=19mm,top=19mm]{geometry}%
\usepackage{xcolor,xcoffins,blindtext}%
\NewCoffin \BodyGrid%
\NewCoffin \CoffinA%
\NewCoffin \CoffinB%

\usepackage{tikz}%
\usepackage{everypage}%

\newlength{\shiftxodd}%
\setlength{\shiftxodd}{\dimexpr(1in+\hoffset+\oddsidemargin+0.5\textwidth)\relax}%
\newlength{\shiftxeven}%
\setlength{\shiftxeven}{\dimexpr(1in+\hoffset+\evensidemargin+0.5\textwidth)\relax}%
\newlength{\shifty}%
\setlength{\shifty}{\dimexpr(-1in-\voffset+\headheight-0.5\textheight)\relax}%

\newcommand{\InitBodyGrid}{%
\SetVerticalCoffin \BodyGrid {176mm} {\color{green!20!white}\rule{\textwidth}{\textheight}}% just to make it visible
\SetVerticalPole \BodyGrid {PoleColA} {0mm}%
\SetVerticalPole \BodyGrid {PoleColB} {30mm}%
\SetVerticalPole \BodyGrid {PoleColC} {60mm}%
\SetVerticalPole \BodyGrid {PoleColD} {90mm}%
\SetVerticalPole \BodyGrid {PoleColE} {120mm}%
\SetVerticalPole \BodyGrid {PoleColF} {150mm}%
\SetHorizontalPole \BodyGrid {PoleRowA} {236mm}%
\SetHorizontalPole \BodyGrid {PoleRowB} {206mm}%
\SetHorizontalPole \BodyGrid {PoleRowC} {176mm}%
\SetHorizontalPole \BodyGrid {PoleRowD} {146mm}%
\SetHorizontalPole \BodyGrid {PoleRowE} {116mm}%
\SetHorizontalPole \BodyGrid {PoleRowF} {86mm}%
\SetHorizontalPole \BodyGrid {PoleRowG} {56mm}%
\SetHorizontalPole \BodyGrid {PoleRowH} {26mm}%
}%

\AddEverypageHook{%
\Ifthispageodd{%
\begin{tikzpicture}[remember picture, overlay]%
\node [xshift=\shiftxodd,yshift=\shifty]  at (current page.north west) {\TypesetCoffin \BodyGrid};%
\end{tikzpicture}%
}{%
\begin{tikzpicture}[remember picture, overlay]%
\node [xshift=\shiftxeven,yshift=\shifty]  at (current page.north west) {\TypesetCoffin \BodyGrid};%
\end{tikzpicture}%
}}%

\begin{document}%

\InitBodyGrid% 

\SetVerticalCoffin \CoffinA {26mm} {\rule{26mm}{26mm}}%
\JoinCoffins \BodyGrid [PoleColF,PoleRowC] \CoffinA [l,t]%
\SetVerticalCoffin \CoffinB {26mm} {\rule{26mm}{26mm}}%
\JoinCoffins \BodyGrid [\BodyGrid-PoleColC,\BodyGrid-PoleRowG] \CoffinB [l,t] %

\blindtext\newpage\InitBodyGrid%

\SetVerticalCoffin \CoffinA {26mm} {\rule{26mm}{26mm}}%
\JoinCoffins \BodyGrid [PoleColF,PoleRowH] \CoffinA [l,t]%
\SetVerticalCoffin \CoffinB {26mm} {\rule{26mm}{26mm}}%
\JoinCoffins \BodyGrid [\BodyGrid-PoleColA,\BodyGrid-PoleRowC] \CoffinB [l,t] %

\blindtext\newpage\InitBodyGrid\blindtext%

\end{document}%
0

This solution answers the question of resetting the created grid, to be reused on another page with new data.

The proposed solution uses memoir class because I am familiar with geometric setting of the page, but this is of no consequence for the solution. There is no need to check for odd or even pages as the grid is a zero dimension text object, typeset at the current insertion point: the first line (after issuing \newpage) at left text border, and [twoside]memoir takes care of the odd and even margins. Here the spine margin is half the edge margin (a recommended choice for a book) to show how it works.

A grid of red lines is included to verify that the figures landed at the proper intersections of rows and columns.

I found that including the join of Zerox --a zero dimension coffin-- in the initialization code makes a notation like [\GridXY-PoleColA, \GridXY-PoleRowF] usable for all the joins in the document, including the first, and it doesn't seem to cause any harm.

The limitation, which I do not do if there is solution with this scheme, is that the restart must be invoked every new page, no "raw" grid memory. Once used it is lost. So it must be inserted manually in the corresponding place. It will be placed at the current insertion point, wherever it is, as the last image shows.

% !TeX TS-program = lualatex

\documentclass[10pt,
a5paper,
twoside,
openright
]
{memoir}

\RequirePackage{luacode}

\usepackage{xcoffins}
\usepackage{graphicx}
\usepackage{calc}
\RequirePackage{latexcolors}

%% set page parameters for memoir
\linespread{1.250000}\selectfont
\setlength{\topskip}{\baselineskip}
\setstocksize{9in}{6in} % 6 x 9 in
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settrims{0pt}{0pt}
\setlxvchars
\settypeblocksize{*}{1.0\lxvchars}{1.6}  % 1.6 aspect ratio of text area, line = 65 chars
\setlength{\headheight}{30pt}
\setlength{\footskip}{20pt}
\setulmargins{90pt}{*}{*}
\setlrmargins{*}{*}{2} % edge = spine x2 
\setheaderspaces{*}{30pt}{*} % Sets the spacing above and below the header
\setmarginnotes{0.01pt}{20pt}{\onelineskip} 
\checkandfixthelayout%
% ends setting of the page

\usepackage{kantlipsum}% dummy text
\usepackage{pifont}% big numbers

\newcommand{\hairlinexvii}[1][green]{% to test text and grid alignment
\leavevmode\kern-0.1pt %
\smash{\color{#1}\vrule height 50pt depth 450pt width 0.1pt}%
\kern-0.1pt}

%%********************** symbols for fun
\NewCoffin\Pxi
\NewCoffin\Pxii
\NewCoffin\Pxiii
\NewCoffin\Pxiv
\NewCoffin\Pxv
\NewCoffin\Pxvi
\NewCoffin\Pxvii
\NewCoffin\Pxviii
\NewCoffin\Pxix

\newcommand{\formatPxi}{\color{capri}\fontsize{64}{10}}
\newcommand{\formatPxii}{\color{carnelian}\fontsize{64}{10}}
\newcommand{\formatPxiii}{\color{pear}\fontsize{64}{10}}

\SetHorizontalCoffin\Pxi{\formatPxi\ding{182}} %#1
\SetHorizontalCoffin\Pxii{\formatPxi\ding{183}}
\SetHorizontalCoffin\Pxiii{\formatPxi\ding{184}}
\SetHorizontalCoffin\Pxiv{\formatPxii\ding{185}}
\SetHorizontalCoffin\Pxv{\formatPxii\ding{186}}
\SetHorizontalCoffin\Pxvi{\formatPxii\ding{187}}
\SetHorizontalCoffin\Pxvii{\formatPxiii\ding{188}}
\SetHorizontalCoffin\Pxviii{\formatPxiii\ding{189}}
\SetHorizontalCoffin\Pxix{\formatPxiii\ding{190}} %#9

%%********************** GRID
\NewCoffin\GridXY
\NewCoffin\Zerox

\NewCoffin\Hrule
\NewCoffin\Vrule

\SetHorizontalCoffin\Vrule{\color{red}\rule{0.1pt}{1.1\textheight}} 
\SetHorizontalCoffin\Hrule{\color{red}\rule{1.25\textwidth}{0.1pt}}

\newcommand{\SetGrid}{%
    \SetHorizontalCoffin\GridXY{}   
    \SetVerticalPole \GridXY {PoleColA} {0mm}%
    \SetVerticalPole \GridXY {PoleColB} {25mm}%
    \SetVerticalPole \GridXY {PoleColC} {50mm}%
    \SetVerticalPole \GridXY {PoleColD} {75mm}%
    \SetVerticalPole \GridXY {PoleColE} {100mm}%
    \SetVerticalPole \GridXY {PoleColF} {125mm}%
    \SetHorizontalPole \GridXY {PoleRowA} {-175mm}%
    \SetHorizontalPole \GridXY {PoleRowB} {-150mm}%
    \SetHorizontalPole \GridXY {PoleRowC} {-125mm}%
    \SetHorizontalPole \GridXY {PoleRowD} {-100mm}%
    \SetHorizontalPole \GridXY {PoleRowE} {-75mm}%
    \SetHorizontalPole \GridXY {PoleRowF} {-50mm}%
    \SetHorizontalPole \GridXY {PoleRowG} {-25mm}%
    \SetHorizontalPole \GridXY {PoleRowH} {0mm}%
    \JoinCoffins*\GridXY [PoleColA, PoleRowA] \Zerox [l,t] % zero dimension coffin
%   \JoinCoffins*\GridXY [\GridXY-PoleColC,\GridXY-PoleRowC] \Pxix [hc,vc]  % print #9  for testing grid       
\LineGrid % for testing X Y alignmen
}

\newcommand{\LineGrid}{% for testing X Y alignment
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowH] \Vrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColB, \GridXY-PoleRowH] \Vrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColC, \GridXY-PoleRowH] \Vrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColD, \GridXY-PoleRowH] \Vrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColE, \GridXY-PoleRowH] \Vrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColF, \GridXY-PoleRowH] \Vrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowA] \Hrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowB] \Hrule [l,t]% 
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowC] \Hrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowD] \Hrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowE] \Hrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowF] \Hrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowG] \Hrule [l,t]%
    \JoinCoffins*\GridXY [\GridXY-PoleColA, \GridXY-PoleRowH] \Hrule [l,t]%
}   
%%**********************    

\begin{document}
\setlength{\parindent}{1.5em}

\SetGrid  %init & Set Grid  
\JoinCoffins*\GridXY [ \GridXY-PoleColA, \GridXY-PoleRowH] \Pxi [hc,vc]%
\JoinCoffins*\GridXY [\GridXY-PoleColA,\GridXY-PoleRowF] \Pxii[hc,vc] %
\noindent\TypesetCoffin\GridXY %print 1 &2

\noindent\hairlinexvii
{\sffamily \color{blue} 3. \kant[3]}

\newpage

\SetGrid    
\JoinCoffins*\GridXY [\GridXY-PoleColC,\GridXY-PoleRowE] \Pxiii [hc,vc]%        
\JoinCoffins*\GridXY [\GridXY-PoleColD,\GridXY-PoleRowE] \Pxii [hc,vc] %        
\JoinCoffins*\GridXY [\GridXY-PoleColC,\GridXY-PoleRowB] \Pxiv [hc,vc] %        
\noindent\TypesetCoffin\GridXY  %print 2, 3 & 4
\noindent\hairlinexvii

{\sffamily \color{blue} 1. \kant[1]}
\newpage

\SetGrid        
%\noindent\TypesetCoffin\GridXY% prints nothing, only empty grid lines! >> OK!  
\JoinCoffins*\GridXY [\GridXY-PoleColA,\GridXY-PoleRowF] \Pxvii [hc,vc]%        
\JoinCoffins*\GridXY [\GridXY-PoleColD,\GridXY-PoleRowE] \Pxvi[hc,vc] %     
\JoinCoffins*\GridXY [\GridXY-PoleColE,\GridXY-PoleRowB] \Pxv [hc,vc] % 
\noindent\TypesetCoffin\GridXY% prints 7,6,& 5

\noindent\hairlinexvii
{\sffamily \color{blue} 4-6. \kant[2-6]}
\SetGrid 
\JoinCoffins*\GridXY [\GridXY-PoleColB,\GridXY-PoleRowF] \Pxvii [hc,vc]%        
\JoinCoffins*\GridXY [\GridXY-PoleColB,\GridXY-PoleRowE] \Pxviii[hc,vc] %     
\noindent\TypesetCoffin\GridXY% prints 7,6,& 

\end{document}

p23

p45

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.