\framebox and tabbing not working together

I wanted to frame in a box a text which includes tabbing. Both \framebox and tabbing works fine separately but cannot make them work together.

\framebox{
\begin{tabbing}
\textit{Input:} \hspace*{13mm} \= assd \\
\end{tabbing}
}

• Not sure whether this is an alternative to your usage, but using you can use some \phantoms achieve the appropriate alignment.
– Werner
Sep 4, 2013 at 0:45

You can box the tabbing before framing it; in the following example I show two possibilities; the firs one, using a \vbox and the second one using a varwidth environment from the varwidth package:

\documentclass{article}
\usepackage{varwidth}

\begin{document}

\framebox{%
\vbox{\begin{tabbing}
\textit{Input:} \hspace*{13mm} \= assd \\
\end{tabbing}}%
}

\framebox{\begin{varwidth}{\linewidth}
\begin{tabbing}
\textit{Input:} \hspace*{13mm} \= assd \\
\end{tabbing}
\end{varwidth}}

\end{document}


You seem to be typesetting algorithms; in this case, some dedicated packages such as algorithmicx or listings could be useful for you.

A \framebox expects only material that doesn't split across lines; so we need to box the tabbing; if a minipage contains only a tabbing environment, it will adapt its width to that of the tabbing (if smaller than the stated width).

You are probably better served from a new environment:

\documentclass{article}

\newsavebox{\ftabbingbox}
\newenvironment{ftabbing}
{\begin{lrbox}{\ftabbingbox}
\begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule}
\begin{tabbing}}
{\end{tabbing}
\end{minipage}
\end{lrbox}
\fbox{\usebox{\ftabbingbox}}}

\begin{document}

\begin{ftabbing}
\textit{Input:} \hspace*{13mm} \= assd \\
\end{ftabbing}

\end{document}


Here's an alternative:

\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
\begin{tabular}{|>{\itshape}l@{}l|}
\hline
Input: \hspace*{13mm} & assd \\