3

Consider the input

\documentclass{article}
\begin{document}
\begin{tabbing}
A
\end{tabbing}%
B
{\small\begin{tabbing}
A
\end{tabbing}}%
B
\end{document}

Compiled with pdflatex, it produces

output with shifted B

I'm wondering what's so bad about the combination of tabbing and small that it inserts an indent whereas the tabbing environment alone does not do that? By the way, the same applies to \smaller and \textsmaller from the package relsize. (I'm interested primarily in \smaller, but, as it turns out, the issue is already present with \small.) Of course, one could use \noindent each time you need it, but would it be possible to do this centrally, once and for all pargraphs following {\small\begin{tabbing}...\end{tabbing}}%?

  • 2
    Why not use \begin{tabbing}\small A \end{tabbing}? This will not indent the first line of text that follows the tabbing environment. – leandriis Jun 6 '18 at 16:37
  • 1
    @leandriis that would only make the first cell of the tabbing small – David Carlisle Jun 6 '18 at 16:49
  • 1
    @DavidCarlisle: You're right. This is something I did not have in mind. – leandriis Jun 6 '18 at 16:51
  • @MdAyquassar: Although this question refers to defining a new tabbing-like environment with a different fontsize, you might be interested in it: Tabbing and font size change – leandriis Jun 6 '18 at 16:55
3

The group around tabbing is the culprit. On the other hand, the suggestion of not using the group doesn't work either:

\documentclass{article}
\usepackage[nopar]{lipsum}

\begin{document}
\lipsum[3]
\begin{tabbing}
A\\
B\\
C
\end{tabbing}
\lipsum[3]
\small\begin{tabbing}
A\\
B\\
C
\end{tabbing}
\normalsize
\lipsum[3]
\end{document}

enter image description here

As you can see, the line spacing in the paragraph preceding tabbing is wrong, because it uses the leading for \small. Using \par\small is not a remedy, because if trivlist is started in vertical mode it does differently than when called in paragraph mode.

We can instead define a specific environment that issues \small at the proper place and doesn't need explicitly reverting the font size. In this version, \small is issued when smalltabbing and the inner \trivlist have already started, so its effect will vanish at \end{smalltabbing} (after the matching \endtrivlist).

\documentclass{article}
\usepackage{etoolbox}

\usepackage[nopar]{lipsum} % just for the example

% let's get a copy of \tabbing
\let\smalltabbing\tabbing
\let\endsmalltabbing\endtabbing
% patch \smalltabbing to issue \small at the proper time
\patchcmd{\smalltabbing}{\trivlist}{\trivlist\small}{}{}

\begin{document}
\lipsum[3]
\begin{tabbing}
A\\
B\\
C
\end{tabbing}
\lipsum[3]
\begin{smalltabbing}
A\\
B\\
C
\end{smalltabbing}
\lipsum[3]
\end{document}

enter image description here

A further version where you can specify a font size as optional argument (default \small):

\documentclass{article}
\usepackage{etoolbox}

\usepackage[nopar]{lipsum} % just for the example

\makeatletter
% let's get a copy of \tabbing
\let\x@tabbing\tabbing
\let\endxtabbing\endtabbing
% patch \x@tabbing to issue the font size command at the proper time
\patchcmd{\x@tabbing}{\trivlist}{\trivlist\x@tabbing@size}{}{}
% define `\xtabbing` with an optional argument
\newcommand{\xtabbing}[1][\small]{%
  \let\x@tabbing@size#1\relax
  \x@tabbing
}
\makeatother

\begin{document}
\lipsum[3]
\begin{xtabbing}
A\\
B\\
C
\end{xtabbing}
\lipsum[3]
\begin{xtabbing}[\footnotesize]
A\\
B\\
C
\end{xtabbing}
\lipsum[3]
\end{document}

If you instead do

\newcommand{\xtabbing}[1][]{%
  \let\x@tabbing@size#1\relax
  \x@tabbing
}

calling \begin{xtabbing} alone would choose the current font size, so xtabbing would be the same as tabbing.

  • @MdAyquassar I added an extended version where you can specify the font size you prefer. – egreg Jun 6 '18 at 17:49
1

this is unrelated to \small you would see the same from

\documentclass{article}
\begin{document}
\begin{tabbing}
A
\end{tabbing}%
B
{\begin{tabbing}
A
\end{tabbing}}%
B
\end{document}

You can avoid the group like

\documentclass{article}
\begin{document}
\begin{tabbing}
A
\end{tabbing}%
B
\small
\begin{tabbing}
A
\end{tabbing}
\normalsize 
B
\end{document}
  • 1
    @MdAyquassar like most latex display environments, tabbing uses a new paragraph internally but adjusts everypar so that it looks like a continuation paragraph if there is no blank line before the environment, but a group defeats that, you would see the same with enumerate or display math or ... – David Carlisle Jun 6 '18 at 16:58
  • 1
    You can do better… What happens to a paragraph which contains \small at the outer level? – egreg Jun 6 '18 at 17:25
  • @egreg don't do that (or save and restore the size, but I leave that as an exercise for people stealing ticks) – David Carlisle Jun 6 '18 at 17:48
  • @MdAyquassar I don't mind not getting a tick, it's egreg getting one that is upsetting:-) – David Carlisle Jun 6 '18 at 18:04
  • @MdAyquassar oh no it will be fine (it's more complete than mine as well) ignore us, we just like to argue – David Carlisle Jun 6 '18 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy