6

I want to align text within a tabbing environment without using a new environment. That means flushleft and flushright are not options. Ideally smething like this would be nice:

\begin{tabbing}
\textalign[left]{Hello} \= \textalign[center]{There} \= \textalign[right]{World}
\end{tabbing}

How do I do this though?

5
  • You can use a tabular with {lcr}: \begin{tabular}{lcr}.
    – user11232
    Commented Sep 3, 2015 at 2:39
  • dont want to use tabular because i need to be able to break across pages
    – dopatraman
    Commented Sep 3, 2015 at 2:41
  • Oh. Then can I suggest a longtable or ltablex solution if you don't mind?
    – user11232
    Commented Sep 3, 2015 at 2:56
  • @HarishKumar Already suggested in the answer too :-) Commented Sep 3, 2015 at 2:57
  • From LaTeX Community: In a tabbing environment using the \` command, which will push the text right aligned up to the next tab stop, or the end of the line if there are no more assigned.
    – blackened
    Commented Apr 14, 2018 at 11:24

1 Answer 1

3

You can do something like this:

\documentclass{article} 

\newcommand\textalign[2][]{%
\ifx#1l\relax
  \makebox[0pt][l]{#2}%
\else
  \ifx#1r\relax
    \makebox[0pt][r]{#2}%
  \else  
    \ifx#1c\relax
      \makebox[0pt][c]{#2}%
    \fi\fi\fi
}

\begin{document}

\noindent
\hrulefill

\begin{tabbing}
\=\hspace*{.5\linewidth}\=\hspace{.5\linewidth}\=\kill \\
\> \textalign[l]{Hello} \> \textalign[c]{There} \> \textalign[r]{World} \\
\> \textalign[l]{Longer text} \> \textalign[c]{Another longer text} \> \textalign[r]{Some other text}
\end{tabbing}

\end{document}

enter image description here

but I don't see much use in this. Some other approaches (e.g., boxes or tabular or longtable) without the tabbing would do the same.

You must log in to answer this question.

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