# Indenting text in \tabfill (tabbing environment)

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?

## 1 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}


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}


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.

• If the argument to \tabfill contains real words with some length, as e.g. Include longs words like extracurricular rather than bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla, you'll notice a very poor result with respect to justification and hyphenation, in that the distance between each word is much too large, and no hyphenation occurs. Any way to fix that problem? Nov 4, 2014 at 16:58
• @Sverre Try \RaggedRight (before the setting of \leftskip); you need \usepackage{ragged2e} for that command. Nov 4, 2014 at 17:00
• It fixes the interword space issue, but it doesn't lead to hyphenation where it should. As in my example sentence, you'd expect extra-curricular, but instead you get a lot of white space at the end of the first line, almost equal to the length of the word extracurricular. That is, instead of hyphenating the word, it just pushes the entire word to the next line. Nov 4, 2014 at 17:17
• Is there something in your definition of tabfill that prevents hyphenation? Nov 4, 2014 at 17:19
• @Sverre If I add \RaggedRight and try \tabfill{bla bla bla bla bla bla bla extracurricular bla bla bla}, I get “extracurric-ular“ with hyphenation. The same exact code, with \RaggedRight\leftskip instead of \leftskip (and \usepackage{ragged2e}. Please, ask a new question if you can't solve it. Nov 4, 2014 at 17:22