# [Tex/LaTex] Fill space created by \phantom with other text

spacing

I am looking for a command I am pretty certain to have used before but which I cannot recall (and I did search for it):

I want to create (horizontal) space of some length, e.g. created using \phantom{text}, with some other (shorter) text. It should simply fill the white space for as far as the replacing text reaches, i.e. it does not need to be stretched to fill the whole space.

I hope I explained this sufficiently since providing a MWE is hard without knowing the answer…

You can just put the short text in a box of zero width and then place the phantom afterwards as follows

\makebox[0pt][l]{short}\phantom{my long text}


\documentclass{article}

\begin{document}

XX\makebox[0pt][l]{short}\phantom{my long text}XX

XXmy long textXX

\end{document}