xcoffins——每一页都有主棺材/清理棺材?

xcoffins——每一页都有主棺材/清理棺材?

在 Phelype 解决了我的问题关于网格的极点,我尝试进行下一步。网格应在每个页面上都可用,并且不应与正文中的“正常”文本交互。

everypage工作正常,但在第一次尝试中,我无法用 定位我的网格tikz。据我了解,主棺材杆[H,l]应该与 处于相同的位置(current page.north west),但事实并非如此[hc,vc]。可能是我读得不够仔细……不得不计算偏移量作为解决方法。任何更好的方法都会受到欢迎。

在第二页上,我仍然能找到第一页的棺材内容(当然),但如何清除它呢?除了重新设置棺材及其支柱(为此定义了一个命令),我找不到其他方法。我尝试将 init 命令放在 everypage-hook 的末尾,但这不起作用,可能是因为 shipout 尚未完成。另一方面,我也没有让afterpage-hook 工作。所以,再次欢迎任何更好的方法。谢谢,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}%

答案1

该解决方案回答了重置创建的网格的问题,以便在另一个页面上使用新数据重新使用。

建议的解决方案使用memoir类,因为我熟悉页面的几何设置,但这对解决方案没有影响。无需检查奇数页或偶数页,因为网格是零维文本对象,排版在当前插入点:第一行(发出后\newpage)在左文本边框,并[twoside]memoir处理奇数和偶数边距。这里书脊边距是边缘边距的一半(书籍的推荐选择)以显示其工作原理。

其中包含一个红线网格,用于验证图形是否落在行和列的正确交叉点上。

我发现在初始化代码中包含“零维棺材”的连接Zerox使得类似的符号[\GridXY-PoleColA, \GridXY-PoleRowF]可用于文档中的所有连接(包括第一个连接),并且似乎不会造成任何伤害。

限制是,如果此方案有解决方案,我不会这样做,因为必须每次打开新页面时都调用重新启动,没有“原始”网格内存。一旦使用,它就会丢失。因此必须手动将其插入相应的位置。它将被放置在当前插入点,无论它在哪里,如最后一张图所示。

% !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

相关内容