[Tex/LaTex] Indenting text in \tabfill (tabbing environment)

tabbing

I am not an expert in LaTeX. Thus, the question may sound trivial. I am using the tabbing environment, and I have long lines to wrap. Thus, I am using the \tabfill command in order to do so.

\newcommand\tabfill[1]{%\dimen@\linewidth%
\advance\dimen@\@totalleftmargin%
\advance\dimen@-\dimen\@curtab%
\parbox[t]\dimen@{#1\ifhmode\strut\fi}%
% or, to avoid stretching:
% \parbox[t]\dimen@{\raggedright #1\ifhmode\strut\fi}%
}

The only problem that I have with this command is that the text inside the \tabfill box is aligned to the left margin. I would like that when this text is wrapped (since it is inside a tabbing environment) it is also indented in the rows following the first. Any idea about how to modify this tabfill command in order to achieve this goal? Or any other solution?

Example of what I am looking for:

Column 1                Column 2
bla bla                 bla bla bla bla bla bla bla bla bla bla bla bla
                        bla bla bla bla
bla bla                 bla bla

Code (generating no indent):

\begin{tabbing}
\hspace{3.1cm} \= \kill
Column 1 \> Column 2\\
bla bla \> \tabfill{bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}\\
bla bla \> \tabfill{bla bla}
\end{tabbing}

Does it make sense?

Best Answer

This is what I get from your original code (the first setting to \dimen@ uncommented):

\documentclass{article}
\makeatletter
\newcommand\tabfill[1]{%
  \dimen@\linewidth
  \advance\dimen@\@totalleftmargin
  \advance\dimen@-\dimen\@curtab
  \parbox[t]\dimen@{#1\ifhmode\strut\fi}%
}
\makeatother

\textwidth=.75\textwidth % just to make wrapping more evident

\begin{document}
\begin{tabbing}
\hspace{3.1cm} \= \kill
Column 1 \> Column 2\\
bla bla \> \tabfill{bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}\\
bla bla \> \tabfill{bla bla}
\end{tabbing}
\end{document}

enter image description here

Let's add a \leftskip setting:

\documentclass{article}
\makeatletter
\newcommand\tabfill[1]{%
  \dimen@\linewidth
  \advance\dimen@\@totalleftmargin
  \advance\dimen@-\dimen\@curtab
  \parbox[t]\dimen@{%
    \leftskip=2em\hspace*{-2em}#1\ifhmode\unskip\nobreak\strut\fi}%
}
\makeatother

\textwidth=.75\textwidth % just to make wrapping more evident

\begin{document}
\begin{tabbing}
\hspace{3.1cm} \= \kill
Column 1 \> Column 2\\
bla bla \> \tabfill{bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}\\
bla bla \> \tabfill{bla bla}
\end{tabbing}
\end{document}

enter image description here

If you don't plan using very complicated things inside the argument to \tabfill such as itemized or enumerated lists, this is the simplest solution. If you want to add \raggedright, place it in front of \leftskip.

Related Question