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 trying to replicate, in LaTeX, InDesign's align and distribute tools. This is a snapshot of ID's toolbar:

indesign toolbar

Say I want first to align vertically two objects (texts, graphics, boxes,...), and then align them horizontally, so that they become superimposed and completely centred. So, if the first object were [ ] and the second x, the first step would give me [ ]x and the second [x].

Of course, I can do this with the centre environment and a negative hspace command and a bit of math.

What I would like to get is a more or less generalized (set of) command(s).

I believe this might be easily accomplished in Tikz, but I don't know how to. Or perhaps with the adjustbox package. Although this question is obviously wide, I wonder if someone has already inquired into this issue and can give me some ideas on it.

OK. As requested, this is more or less what I would like to systematise:

\usepackage{graphicx, xcolor, calc}



\section{First Step}
  \setlength{\wthree}{\wone + \wtwo}


\section{Second Step}
  \setlength{\hthree}{\hone + \htwo}

\raisebox{-.25\hthree}{\SecondObject{}}  % Don't know why .5 won't work here...



share|improve this question
This definitely needs a explanatory drawing/image. – yo' Feb 1 '13 at 15:59
You probably want \ooalign; see this answer – egreg Feb 1 '13 at 16:05
@egreg Just tried it. Although it takes care of horizontal alignment (my first step), it doesn't give me vertical alignment (my second step). Furthermore, I would have to calculate beforehand which is the widest object. – NVaughan Feb 1 '13 at 16:41
You don't need to compute any width with \ooalign. You're not taking into account that \colorbox descends below the baseline. Perhaps a better example is needed. – egreg Feb 1 '13 at 16:45
You can determine the center of the box that contains a character but there is no way to determine the "center" of an arbitrary character. See tex.stackexchange.com/a/61357/14500. – Paul Gaborit Feb 2 '13 at 23:17
up vote 7 down vote accepted

You might like the xcoffins package which has very handy ways to join different kinds of boxes (so-called coffins) with another or attach one to another. It is part of the l3experimental bundle which means syntax changes are still possible.

There already are some questions and answers on this site that deal with xcoffins, here's another small example:








% join both coffins at their horizontal and vertical centers:

% \FirstObject now holds the joined coffins:


enter image description here

share|improve this answer
The \JoinCoffins command does exactly what I wanted. Thanks. – NVaughan Feb 2 '13 at 23:19

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.