TransWikia.com

Relative horizontal positioning of a line

TeX - LaTeX Asked by Separatrix on May 16, 2021

How can I set the second line so that the colons have the same horizontal position?

    documentclass{article}

    begin{document}

    hfill foo : bar baz barabbas
    x : y

    end{document}

2 Answers

With the help of a tabular:

documentclass{article}

begin{document}
hfill
begin{tabular}{@{}r@{~:~}l@{}}
foo &  bar baz barabbas
x & y
end{tabular}
end{document}

enter image description here

Correct answer by leandriis on May 16, 2021

A solution with eqparbox:

documentclass{article}
usepackage{eqparbox}

begin{document}

Some text. Some more text. Still some more text. 

hfill eqmakebox[L]{foo :} eqmakebox[R]{bar baz barabbas}
null hfilleqmakebox[L][r]{x :} eqmakebox[R][l]{y}

end{document} 

enter image description here

Answered by Bernard on May 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP