I would like to use an environment to fill a vertical coffin. I find that I can fill the coffin this way, but that the poles get lost, in the sense the top pole (t) is treated as if it lies at the bottom of the coffin (the width also gets lost). I have to set the poles manually.
So, my question is whether there's a way to load the vertical coffin in an environment without losing the poles. In the following MWE, my use of \global
is a hack, and so maybe also the cause of the problem.
Notes: a) I need to use an environment for compatibility with other codes...I know that can get the final result directly without setting the coffin inside the environment and without losing the poles; b) I have seen this thread and its replies, but they don't quite address my question.
\documentclass[10pt]{article}
\usepackage{xcoffins,lipsum,xparse}
\NewCoffin{\CoffinA}
\NewCoffin{\CoffinB}
\DeclareDocumentCommand\SetCoffinB{m}{%
\SetVerticalCoffin{\CoffinB}{100mm}{#1}
}
\NewDocumentEnvironment{coffinB}{+b}{%
\global\SetCoffinB{\noindent#1}%
}{}
\begin{document}
\SetVerticalCoffin{\CoffinA}{100mm}{%
{\Large\bfseries\noindent A Big Heading}%
}
\begin{coffinB}
\lipsum[1]
\end{coffinB}
\SetHorizontalPole \CoffinB {t} {\TotalHeight} % <=== why should this be necessary?
\JoinCoffins\CoffinA[l,b]\CoffinB[l,t](0pt,0pt)
\TypesetCoffin\CoffinA
\end{document}
Without the \SetHorizontalPole
command, I get this result, as if the top pole sits at the bottom of CoffinB:
With the \SetHorizontalPole
for the top pole of CoffinB, I get this result, which is basically what I want:
\global\SetCoffinB
is unlikely to do anything useful, you can not put\global
before arbitrary tex macros it will just apply arbitrarily to the first non expandable token in the expansion of\SetCoffinB
\NewDocumentEnvironment{coffinB}{+b}{\gdef\tmp{\SetCoffinB{\noindent#1}}\aftergroup\tmp}{}
runs without error but I am not sure I understand the question well enough to know if that produces the desired effect.\gdef\tmp{...}\aftergroup\tmp
just a bit? What\global
did for me originally was to get the coffin to exist outside the environment, and I gather that the expansion issue was responsible for the loss of poles?\global
before a macro then you are lucky if anything useful happens, certainly it is by luck not design if it does anything before\SetCoffinB
if for example you try to make a global definition with\global\newcommand\foo{..}
it just makes some internal temp assignment in the implementation of\newcommand
global, it doesn't affect the assignment to\foo
at all.\gdef\tmp{...}\aftergroup\tmp
construction resolve this?