16

I'm experimenting with xcoffins for a cover page (and enjoying myself immensely, BTW, what an ace package).

What I'm trying to to at this moment is fit a logo, some horizontal white space, and a coloured horizontal bar nicely into \textwidth

In my code, below, although the calculation of the length of the horizontal bar works nicely, it seems a bit clunky and 20th-century. I'm especially worried there might be significant overhead in \settowidth{\worki}{\TypesetCoffin{\logo}}. Can anyone suggest a cleaner, more ``modern'' way of doing it?

As a supplementary question: are there any plans to add coffin-specific measuring tools to xcoffins? Perhaps something along the lines of \CoffinWidth{<coffin>}, for example?

PS: I appreciate that xcoffins is work-in-progress and that the interface may still be a bit malleable...

Here's my M(ish)WE:

\documentclass[12pt,a4paper]{memoir}
\semiisopage
\checkandfixthelayout
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{xcoffins}

\begin{document}
\thispagestyle{empty}

\NewCoffin \result
\SetHorizontalCoffin \result {}

\NewCoffin \logo
\SetHorizontalCoffin \logo {\includegraphics[height=2in]{mylogo}}

\NewCoffin \ruleh
\newlength{\worki}
\newlength{\workii}
\settowidth{\worki}{\TypesetCoffin{\logo}}
\setlength{\workii}{\textwidth}
\addtolength{\workii}{-5pt}
\addtolength{\workii}{-\worki}
\SetHorizontalCoffin \ruleh  {\color{blue}\rule{\workii}{1pc}}

\JoinCoffins \result \logo
\JoinCoffins \result[\logo-vc,\logo-r] \ruleh[vc,l](5pt,0pt)

\noindent
\TypesetCoffin \result
\end{document}
  • 3
    Feature requests always welcome! Rules are something that Frank Mittelbach has mentioned as needing attention, for example. I take it that the idea here is that the rule is to take up the 'rest' of the space? – Joseph Wright Nov 10 '11 at 12:47
  • Yes, Joseph, spot on (a vertical version might be nice, too). I'm sure I can think up more challenging examples, though, once I really get my teeth into it... – Brent.Longborough Nov 10 '11 at 12:59
  • 3
    I'm expecting a wealth of amusingly titled questions related to xcoffins. Good times. – Seamus Nov 10 '11 at 13:11
  • @Joseph when speaking of size, maybe a more generalized enquiry possibility would be useful too? E.g., \CoffinSize[<pair of points denoted by poles>] or something along those lines. Brent, it would be great if you would collect thoughts and feature requests when you play along with nails and planks :-) – Frank Mittelbach Jun 30 '12 at 19:30
  • @FrankMittelbach It's more of a 'inter-handle length', but we can certainly add it (looks quite easy). – Joseph Wright Jun 30 '12 at 21:05

1 Answers1

10
\setlength{\worki}{\wd\logo}

A coffin name is also the name of the box register that contains it. It probably is not the "modern" way to do it, and perhaps xcoffins might have an interface for it.

If you want something "modern", then these commands can be defined:

\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\WidthOfCoffin}{m}{ \box_wd:N #1 }
\NewDocumentCommand{\HeightOfCoffin}{m}{ \box_ht:N #1 }
\NewDocumentCommand{\DepthOfCoffin}{m}{ \box_dp:N #1 }
\ExplSyntaxOff

so you can say

\setlength{\worki}{\WidthOfCoffin{\logo}}
egreg
  • 1,121,712