I'm trying to replicate, in LaTeX, InDesign's align and distribute tools. This is a snapshot of ID's 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:
\documentclass{article}
\usepackage{graphicx, xcolor, calc}
\newcommand*{\FirstObject}{\colorbox{black!20}{\quad}}
\newcommand*{\SecondObject}{x}
\begin{document}
\thispagestyle{empty}
\parindent=0pt
\section{First Step}
\newlength{\wone}
\setlength{\wone}{\widthof{\FirstObject{}}}
\newlength{\wtwo}
\setlength{\wtwo}{\widthof{\SecondObject{}}}
\newlength{\wthree}
\setlength{\wthree}{\wone + \wtwo}
\FirstObject{}\hspace*{-.5\wthree}\SecondObject{}
\section{Second Step}
\newlength{\hone}
\setlength{\hone}{\heightof{\FirstObject{}}}
\newlength{\htwo}
\setlength{\htwo}{\heightof{\SecondObject{}}}
\newlength{\hthree}
\setlength{\hthree}{\hone + \htwo}
\FirstObject{}\hspace*{-.5\wthree}%
\raisebox{-.25\hthree}{\SecondObject{}} % Don't know why .5 won't work here...
\end{document}


\ooalign; see this answer – egreg Feb 01 '13 at 16:05\ooalign. You're not taking into account that\colorboxdescends below the baseline. Perhaps a better example is needed. – egreg Feb 01 '13 at 16:45\colorbox. That's why I want a more general solution that doesn't require me to know that, i.e., that works for any two (or more) objects, irrespective of their characteristics. – NVaughan Feb 01 '13 at 16:54Tikz? – NVaughan Feb 02 '13 at 23:48