在製表環境中使用 \hfill

在製表環境中使用 \hfill

我想\hfill在選項卡環境中使用,但似乎沒有效果。我該怎麼做?

微量元素:

\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}

(由於某種原因,我無法上傳螢幕截圖,因為我收到錯誤訊息“無法上傳圖像;伺服器上發生錯誤”)

答案1

我建議使用某種表格環境。這是一個包含包的範例tabularray

\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}

在此輸入影像描述

答案2

您可以透過巨集測量文本\tabset,並使用文字來測量寬度\tabuse。您不需要選項卡環境。

\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

答案3

也許右對齊\`有你想要的效果

\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}

在此輸入影像描述

相關內容