TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:



\NewCoffin \result
\SetHorizontalCoffin \result {}

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

\NewCoffin \ruleh
\SetHorizontalCoffin \ruleh  {\color{blue}\rule{\workii}{1pc}}

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

\TypesetCoffin \result
share|improve this question
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
I'm expecting a wealth of amusingly titled questions related to xcoffins. Good times. – Seamus Nov 10 '11 at 13:11
+1 for the question title. – lockstep Nov 10 '11 at 16:09
@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
up vote 10 down vote accepted

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:

\NewDocumentCommand{\WidthOfCoffin}{m}{ \box_wd:N #1 }
\NewDocumentCommand{\HeightOfCoffin}{m}{ \box_ht:N #1 }
\NewDocumentCommand{\DepthOfCoffin}{m}{ \box_dp:N #1 }

so you can say

share|improve this answer
The question is partly where does 'design' end and 'programming' begin (at which point you'd use \box_wd:N and the \coffin_... functions). – Joseph Wright Nov 10 '11 at 12:59
It may not be modern, but it's already a lot crisper than mine. Thanks. – Brent.Longborough Nov 10 '11 at 13:01
@JosephWright: That's the eternal riddle. I think the divide is between "users" and "programmers", but I admit that in TeX that's also a bit blurred. – Brent.Longborough Nov 10 '11 at 13:02
Maybe \WidthOf{\logo}? – egreg Nov 10 '11 at 13:11
+1 +Tick --- Nice one, Enrico. Grazie. I've even managed to put it straight into the sums without its own length variable: \addtolength{\worki}{-\WidthOfCoffin{\logo}} – Brent.Longborough Nov 10 '11 at 20:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.