# Tabbing and font size change

As a follow up of a previous question Paragraph break when combining tabbing and font change I need to type snippets of code within a tabbing environment, but sometimes I need to change the size of the font for writing these snippets as follows

\documentclass[11pt,a4paper]{article}

\newenvironment{sftabbing}
{\sffamily\tabbing}
{\endtabbing}

\newenvironment{sfsmtabbing}
{\relax\sffamily\small\tabbing}
{\endtabbing}

\newenvironment{sfscstabbing}
{\sffamily\scriptsize\tabbing}
{\endtabbing}

\begin{document}

First paragraph blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\begin{sftabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
first paragraph continues here blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

Second paragraph blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\begin{sfsmtabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sfsmtabbing}
second paragraph continues here blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

Third paragraph blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\begin{sfscstabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sfscstabbing}
third paragraph continues here blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

\end{document}


The problem is that the environments I defined for doing this do not make the font size change local to the environment and therefore the space between the lines in the enclosing paragraphs is changed also.

-

I'd use one environment, with an optional argument; the environment does not change the font size if no optional argument is specified.

However, since the size declaration has to be given before the tabbing environment starts, because tabbing cells form groups, we need to terminate the current paragraph.

\documentclass[11pt,a4paper]{article}

\newenvironment{sftabbing}[1][]
{\par\sffamily#1\tabbing}
{\endtabbing}

\newcommand{\blah}{blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah}

\begin{document}

First paragraph \blah
\begin{sftabbing}
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
first paragraph continues here \blah

Second paragraph \blah
\begin{sftabbing}[\small]
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
second paragraph continues here \blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah

Third paragraph \blah
\begin{sftabbing}[\scriptsize]
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some code \\
some code some code some code some code some code some text
\end{sftabbing}
third paragraph continues here \blah

\end{document}


-

The font size is local to the environment but you change the baselineskip before ending the previous paragraph.

\newenvironment{sftabbing}
{\par\sffamily\tabbing}
{\endtabbing\par}

\newenvironment{sfsmtabbing}
{\par\relax\sffamily\small\tabbing}
{\endtabbing\par}

\newenvironment{sfscstabbing}
{\par\sffamily\scriptsize\tabbing}
{\endtabbing\par}

-
Many thanks David for your prompt and great solutions, as always. Esteban –  Esteban Zimanyi Mar 10 at 9:50