0

I continued my grid-setting-project with xcoffins and converted the code to latex3.

From an earlier question I learned, that when I first join two coffins the poles are kept as <pole name>, later on as <coffin name>-<pole name>.

Attaching the body-coffin to the page-coffin (1st join) works fine with

\coffin_attach:NnnNnnnn \l__jgrid_page_coffin { T } { l } \l__jgrid_body_coffin { T } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim }

But I'm stuck when attaching the next coffin. \coffin_show_structure:N \l__jgrid_page_coffin has the output

>  \l__jgrid_page_coffin -T  =>  {0.0pt}{845.04684pt}{1000pt}{0pt}
>  \l__jgrid_body_coffin -l  =>  {54.06023pt}{116.29182pt}{0pt}{1000pt}

but he following code does not work:

\coffin_attach:NnnNnnnn \l__jgrid_page_coffin { \l__jgrid_page_coffin -T } { \l__jgrid_page_coffin -l } \l__jgrid_head_coffin { T } { l } { \dim_use:N \l__jgrid_head_offsetx_dim } { \dim_use:N \l__jgrid_head_offsety_dim }

How do I have to "build" <l__jgrid_page_coffin>-<T> ? In case this is a trivial question, please keep in mind that these are my first steps in latex3. Thanks a lot, Jens.

1 Answers1

1

2nd answer:

After some more testing I (hopefully) understand better, that/how positioning differs depending on the function used.

\coffin_attach:NnnNnnnn \l__jgrid_page_coffin { T } { l } \l__jgrid_foot_coffin { t } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim - \textheight-\baselineskip }

and

\coffin_join:NnnNnnnn \l__jgrid_page_coffin {  \l__jgrid_page_coffin-T } {  \l__jgrid_page_coffin-l } \l__jgrid_foot_coffin { T } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim - \textheight-\baselineskip}

produce the same results in sence of positioning. While with \coffin_join the bounding box of the first coffin is updated to enclose the bounding box of both, \coffin_attach leaves the first coffin unchanged.

1st answer: Thanks to Ulrikes comment, I might have found the answer by reducing my code to a MWE. It seems to me, that the formerly received explanation "at first the poles are kept as (pole-name), later on as (coffin name-pole name)" is only valid for the xcoffins-DocumentFunctions ?!

Can someone confirm this, or is it just working in this simple MWE?

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

\setlength{\parindent}{0mm}%
\pagestyle{empty}%
\usepackage[width=164mm,height=236mm,left=19mm,top=19mm]{geometry}%
\usepackage{expl3,xparse,xcolor,xcoffins,xtemplate,layout,blindtext,tikz,everypage}%

%%%%%%%%%%%%%%%%
\ExplSyntaxOn
% page
\coffin_new:N \l__jgrid_page_coffin
\dim_new:N    \l__jgrid_page_width_dim
\dim_new:N    \l__jgrid_page_height_dim
\dim_new:N \l__jgrid_page_offsetx_dim
\dim_new:N \l__jgrid_page_offsety_dim
\tl_new:N \l__jgrid_page_main_content_tl
\dim_set:Nn \l__jgrid_page_width_dim { \paperwidth }
\dim_set:Nn \l__jgrid_page_height_dim { \paperheight }
% just to make coffin visible fpr MWE
\tl_set:Nn \l__jgrid_page_content_tl { \color{green!10!white}\rule{ \dim_use:N \l__jgrid_page_width_dim }{ \dim_use:N \l__jgrid_page_height_dim } }

% body
\coffin_new:N \l__jgrid_body_coffin
\dim_new:N    \l__jgrid_body_width_dim
\dim_new:N    \l__jgrid_body_height_dim
\dim_new:N \l__jgrid_body_offsetx_dim
\dim_new:N \l__jgrid_body_offsety_dim
\tl_new:N \l__jgrid_body_content_tl
\dim_set:Nn \l__jgrid_body_width_dim { \textwidth }
\dim_set:Nn \l__jgrid_body_height_dim { \textheight }
% just to make coffin visible for MWE
\tl_set:Nn \l__jgrid_body_content_tl { \color{red!10!white}\rule{ \dim_use:N \l__jgrid_body_width_dim }{ \dim_use:N \l__jgrid_body_height_dim } }

% foot
\coffin_new:N \l__jgrid_foot_coffin
\dim_new:N    \l__jgrid_foot_width_dim
\dim_new:N    \l__jgrid_foot_height_dim
\dim_new:N \l__jgrid_foot_offsetx_dim
\dim_new:N \l__jgrid_foot_offsety_dim
\tl_new:N \l__jgrid_foot_content_tl
\dim_set:Nn \l__jgrid_foot_width_dim { \textwidth }
\dim_set:Nn \l__jgrid_foot_height_dim { 30mm }
% just to make coffin visible for MWE
\tl_set:Nn \l__jgrid_foot_content_tl { \color{blue!10!white}\rule{ \dim_use:N \l__jgrid_foot_width_dim }{ \dim_use:N \l__jgrid_foot_height_dim } }


\DeclareDocumentCommand { \InitializePage } {  }
{ 
\vcoffin_set:Nnn \l__jgrid_page_coffin  { \dim_use:N \l__jgrid_page_width_dim } { \tl_use:N \l__jgrid_page_content_tl }
\vcoffin_set:Nnn \l__jgrid_body_coffin  { \dim_use:N \l__jgrid_body_width_dim } { \tl_use:N \l__jgrid_body_content_tl }
\vcoffin_set:Nnn \l__jgrid_foot_coffin  { \dim_use:N \l__jgrid_foot_width_dim } { \tl_use:N \l__jgrid_foot_content_tl }

\dim_set:Nn \l__jgrid_body_offsety_dim { -1in+\voffset+\headheight }
\int_if_odd:nTF { \thepage } { \dim_set:Nn \l__jgrid_body_offsetx_dim { 1in+\hoffset+\oddsidemargin} } { \dim_set:Nn \l__jgrid_body_offsetx_dim { 1in+\hoffset+\evensidemargin} }

\coffin_attach:NnnNnnnn \l__jgrid_page_coffin { T } { l } \l__jgrid_body_coffin { T } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim }
\coffin_attach:NnnNnnnn \l__jgrid_page_coffin { T } { l } \l__jgrid_foot_coffin { T } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim - \textheight-\baselineskip}
}

\DeclareDocumentCommand { \TypesetPage } {  }
{ 
\coffin_typeset:Nnnnn \l__jgrid_page_coffin { T } { l } { 0pt }{ 0pt }   
%\coffin_show_structure:N \l__jgrid_page_coffin
}

\ExplSyntaxOff
%%%%%%%%%%%%%%%%

\AddEverypageHook{%
\tikz[remember picture, overlay]{\node [xshift=0.5\paperwidth,yshift=-0.5\paperheight]  at (current page.north west) {\TypesetPage}}%
}%

\begin{document}%
\InitializePage\blindtext\clearpage
\InitializePage\blindtext
\end{document}%
  • 1
    No, the <coffin name>-<pole name> thingy is added at the implementation level in l3coffins. xcoffins only adds the syntatic sugar for default arguments and so on (\coffin_show_structure:N is your friend :-). Your output looks fine to me though... What's wrong? – Phelype Oleinik Mar 16 '20 at 13:58
  • Hi Phelype, I'm not sure if something is wrong. In latex2 I had to use
    \JoinCoffins \PageGrid [\PageGrid-l,\PageGrid-t] \NextCoffin [l,t]
    
    – Jensolig Mar 16 '20 at 15:20
  • So I tried the same "method" in Latex3. But here it only works without the extension of <coffin-name>. – Jensolig Mar 16 '20 at 15:29
  • We are probably not getting communication straight (my TeX is better than my english :-). <coffin name> prefixing should work. For example try replacing the second \coffin_attach:NnnNnnnn line by: \coffin_attach:NnnNnnnn \l__jgrid_page_coffin { \l__jgrid_body_coffin-b } { \l__jgrid_body_coffin-l } \l__jgrid_foot_coffin { t } { l } { 0pt } { -\baselineskip }. Thhat seems to be the only “issue” with your code: you are using offsets instead of the proper handles. Other than that, I don't immediately see what's the problem... – Phelype Oleinik Mar 16 '20 at 15:42
  • Hi Phelype, my TeX is much worse than my English ;-) You are totally right, this works as long as I always attach a new coffin to the last one used. Unfortunately in the MWE it is not clear, that it is just an example of the layout in mind. E.g. I want chapter name (on non-chapter-pages) to be rotated and positioned at the inner margin, which is outside the normal header-coffin. Instead of thinking about "which coffin is last on this particular page" I just wanted to position every coffin to the page-coffin. – Jensolig Mar 16 '20 at 16:35
  • 1
    You don't have to use the last one: all coffins are available in the page coffin (unless overwritten), as well as the page coffin itself. You can attach to the page coffin using { \l__jgrid_page_coffin-<hpole> } { \l__jgrid_page_coffin-<vpole> } (once initialised) or, since the page coffin shouldn't grow in size, simply { <hpole> } { <vpole> }. In my example I used the body coffin's handles because it seemed natural to attach the footer to the bottom of the body, but you can certainly use the page for that, you just have to use the right offsets (as your second \coffin_attach: does). – Phelype Oleinik Mar 16 '20 at 16:51
  • After some more testing I (hopefully) understand better. In case of ATTACH:
    \coffin_attach:NnnNnnnn \l__jgrid_page_coffin { T } { l } \l__jgrid_foot_coffin { t } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim - \textheight-\baselineskip }
    

    and in case of JOIN:

    \coffin_join:NnnNnnnn \l__jgrid_page_coffin {  \l__jgrid_page_coffin-T } {  \l__jgrid_page_coffin-l } \l__jgrid_foot_coffin { T } { l } { \dim_use:N \l__jgrid_body_offsetx_dim } { \dim_use:N \l__jgrid_body_offsety_dim - \textheight-\baselineskip}
    

    give same results! Thanks.

    – Jensolig Mar 16 '20 at 17:45
  • 1
    Glad you sorted it out! :D Let me just add one final remark: The only difference between attach and join is that with join the bounding box of the <coffin 1> should be updated to enclose the bounding box of both (the original) <coffin 1> and <coffin 2>. attach doesn't change the bounding box (that of <coffin 1> is used). Thus after join the standard poles (l hc r t T vc b B) may shift when the bounding box is updated (this is what might be causing you trouble). – Phelype Oleinik Mar 16 '20 at 18:41