0

I'd like to use \hfill within a tabbing environment, but it seems to have no effect. How can I do it?

MWE:

\documentclass{article}

\setlength{\parindent}{0pt}

\begin{document}

\begin{tabbing}
Foo bar baz: \= Lib  \hfill Bizim\\
Foo: \> Kip\\
\end{tabbing}

Foo bar baz: Lib  \hfill Bizim

Foo: Kip

\end{document}

(I can for some reason not upload a screen shot, as I get an error message "Failed to upload image; an error occurred on the server")

6

3 Answers 3

1

I suggest to use a tabular environment of some kind. Here an example with the tabularray package:

\documentclass{article}

\setlength{\parindent}{0pt}

\usepackage[showframe]{geometry} % just to show that the text is aligned with the margin
\usepackage{tabularray}

\begin{document}

\begin{tblr}{@{}lX@{}}
Foo bar baz: & Lib  \hfill Bizim\\
Foo: & Kip\\
\end{tblr}

\end{document}

enter image description here

1

You can measure the text by \tabset macro and use the text to measured width by \tabuse. You need not tabbing environment.

\newdimen\tabw
\def\tabset#1{\par \setbox0=\hbox{#1}\tabw=\wd0 \leavevmode\box0 }
\def\tabuse#1{\par \leavevmode\hbox to\tabw{#1\hss}}

\tabset {Foo bar baz:} \ Lib  \hfill Bizim
\tabuse {Foo:}         \ Kip
1

Maybe right align \` has the effect you intend

\begin{tabbing}
\hspace{0.2\textwidth} \= \hspace{0.2\textwidth} \= \hspace{0.2\textwidth}  \kill   % \kill lets the definition line disappear
Foo bar baz: \> Lib \` right aligned Bizim\\
Foo: \> Kip \> Bizim \\
\end{tabbing}

enter image description here

2
  • This seems to be the easiest solution.
    – Sverre
    Oct 13, 2022 at 14:59
  • It would be good if the person who downvoted this explains why this is not a good solution ...
    – Sverre
    Oct 13, 2022 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .