# Where does this vertical space come from?

I (thankfully) received couple of answers to one of my previous questions and while testing each one out I noticed a behavior to which I found no solution.

This is my MWE:

\documentclass[10pt,english]{article}
\usepackage[english]{babel}
\usepackage[protrusion=true,expansion=true, tracking=true]{microtype}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[showframe, paperwidth=6in,paperheight=9in]{geometry}
\geometry{tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\pagestyle{empty}

%Needed for bridge related tabular enviroments defined below
\usepackage{array}

\raggedbottom

%********************************************************************************
%Use MnSymbol suit symbols
\DeclareFontFamily{U}{MnSymbolCards}{}

\DeclareFontShape{U}{MnSymbolCards}{m}{n}{
<-6>  s*[1.2] MnSymbolC5
<6-7>  s*[1.2] MnSymbolC6
<7-8>  s*[1.2] MnSymbolC7
<8-9>  s*[1.2] MnSymbolC8
<9-10> s*[1.2] MnSymbolC9
<10-12> s*[1.2] MnSymbolC10
<12->   s*[1.2] MnSymbolC12}{}

\newcommand{\mndiamond}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A2}}}
\newcommand{\mnheart}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A3}}}
\newcommand{\mnclub}{{\usefont{U}{MnSymbolCards}{m}{n}\symbol{"A5}}}

\renewcommand{\c}{\mnclub}
\renewcommand{\d}{\mndiamond}
\newcommand{\h}{\mnheart}
%********************************************************************************

\def\hand#1#2#3#4#5{\vtop{
\hbox{\textls[100]{\textsc{#1}}}
\handA \s{#2}
\handA \h{#3}
\handA \d{#4}
\handA \c{#5}
}}
\def\handA#1#2{\hbox{\hbox to1em{\hss#1\hss}\handB#2\relax}}
\def\handB#1{\ifx#1\relax\else #1\if1#1\else\kern2pt \fi\expandafter\handB\fi}

\newcommand{\bd}[4]{
\begin{tabular}[b]{ m{6em} m{6em} m{6em}}
& #1 & \\
#2 &  & #3\\
& #4 &
\end{tabular}
}

\makeatother

\begin{document}
\noindent $1$THEIR UNTO THEM PLACE CANNOT SIGNS DARKNESS.

\bd
{\hand{NORTH}{J652}{AQJ972}{J}{103}}
{\hand{WEST}{10}{K83}{Q973}{AQJ92}}
{\hand{EAST}{KQ974}{10543}{652}{5}}
{\hand{SOUTH}{A83}{\textemdash}{AK1084}{K8764}}

\noindent THEIR UNTO TAKQJAKQJAQKHJ AKQJAKQJAQKHJ ARKNESS.

\hand{NORTH}{J652}{AQJ972}{J}{103}

THEIR UNTO THEM AKQJAKQJAQKHJ DARKNESS.

\bd
{North}
{West}
{East}
{South}

THEIR UNTO THEM PLACE CANNOT SIGNS DARKNESS.
\end{document}


This my pdfLaTeX output:

I am primarily concerned about the vertical space between region 1 and the following paragraph. The vertical space is not a byproduct of the macro,

\def\hand#1#2#3#4#5{\vtop{
\hbox{\textls[100]{\textsc{#1}}}
\handA \s{#2}
\handA \h{#3}
\handA \d{#4}
\handA \c{#5}
}}
\def\handA#1#2{\hbox{\hbox to1em{\hss#1\hss}\handB#2\relax}}
\def\handB#1{\ifx#1\relax\else #1\if1#1\else\kern2pt \fi\expandafter\handB\fi}


because in region two the same macro produces no top or bottom vertical space.

Also, I suppose it is not a byproduct of the macro:

\newcommand{\bd}[4]{
\begin{tabular}[b]{ m{6em} m{6em} m{6em}}
& #1 & \\
#2 &  & #3\\
& #4 &
\end{tabular}
}


Because the same macro (essential a tabular environment) did not produce the same vertical space in region 3.

My question: What produces the vertical bottom spacing in region 1?

Also, there are some minor spacing problems in the output; is it possible to ask the LaTeX engine not to try to be smart and arrange (add or subtract) any kind of vertical spacing whatsoever?

This space comes from using \vtop without realizing that \leavevmode should precede it.

When tabular processes a p cell (or m or b), it ensures the first line and last line in it have a strut; but this can only be done when the paragraph in the cell has started and \vtop doesn't do it. So you have the box, still in vertical mode, and then the final strut coinciding with the initial one.

Solution: if you really need to use \vtop (you don't for that job), be sure to have \leavevmode in front of it.

Here's the result if I change \vtop to \leavevmode\vtop in the definition of \hand:

Now you clearly see why you don't want \vtop.

• Thanks for your answer. Is there an explanation for the vertical (tiny) spacing between the diagram in region 2 and the paragraph above it? (There is no vertical spacing with the diagram in region 1 and text above it.) – blackened Sep 11 '15 at 15:00
• @blackened There is, with my correction. I'm not sure you want your hands to be displayed without some white space before and after them. – egreg Sep 11 '15 at 15:03
• This is very bad approach to add \leavevmode in the macro which generates box. Then usage of such macro leaves vertical mode and inserts \parindent . Both is strictly undesirable in normal situations. – wipet Sep 11 '15 at 17:26
• @wipet It's what all box making macros of LaTeX do. So what users expect from boxes. Consistency is the key, which of course doesn't prohibit to use \hbox or \vbox without \leavevmode in macros, provided these macro don't break the normal conventions at point of use. – egreg Sep 11 '15 at 17:29
• You write: LaTeX hides normal behaviour of boxes from users. And users are confused (like here). This is very bad concept to hide TeX primitive behaviour.. That is all. – wipet Sep 11 '15 at 17:33

The space isn't byproduct of my macro, of course. But my macro \hand produces box. The tabular item starts in vertical mode, places this box and finally it starts horizontal mode (I don't know why). This horizontal mode puts empty line after #4 parameter in tabular environment.

You can type \noindent#4 and, of course, \noindent#3, \noindent#2 and \noindent#1 in the tabular environment (macro \bd).

Edit Now, I do know why the horizontal mode is started at the end of the tabular item. The \@finalstrut is expanded here for putting strut at the end of the item. I did look into latex.ltx but this was not good idea. The macro is programmed as something obscure:

\def\@finalstrut#1{%
\unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1}


Why there is \nobreak immediately before \vrule? This is strange. Why only in horizontal mode the penalty is applied? And if horizontal mode isn't in current then it is started due to \vrule. It is better to not look into latex.ltx file (for keeping good state of mind).

Edit2 I suggest to replace the \bd macro implemented by tabular to another macro which manipulates only with boxes. Then the \leavevmode nor \noindent is not needed:

\def\bd#1#2#3#4{\vbox{
\bx{}{#1}{}
\bx{#2}{}{#3}
\bx{}{#4}{}
}}
\def\bx#1#2#3{\hbox{\rlap{#1}\kern8em\rlap{#2}\kern8em\rlap{#3}\kern6em}}

• Contrary to what you claim, the space is a byproduct of your macros. – egreg Sep 11 '15 at 14:47
• @egreg No. My macros creates box. If it is used in the environment where starting to horizontal mode is processed at the end of this environment then this is problem of this environment, no the mentioned box. Please, don't blame. If you put a boxed image (for example) in such environment then the same problem occurs. BTW: note that user accepted your \ExplSyntaxOn solution but he used mine solution. – wipet Sep 11 '15 at 15:49
• @wipet Your macro behaves differently in vertical and horizontal mode, which is a “don't do it” in LaTeX. Since LaTeX is assumed in the question, you should add \leavevmode in front of \vtop. That's all. – egreg Sep 11 '15 at 15:55
• \includegraphics generates box. \framebox generates box. It is normal that user needs sometimes box, not starting paragraph (which creates new box with \hsize width, what isn't always desired). – wipet Sep 11 '15 at 15:59
• @wipet Woah! Guys, chill. It is not worth breaking each other over a question. I am thankful to both of you. Also, I specifically mentioned that I am testing various approaches. The above problem is not necessarily specific to your macro—I have similar other vertical spacing problems, and I am simply trying to understand the underlying issue(s). StackExchange should perhaps come up with another solution—when there are multiple answers, and the OP chooses one as the “accepted” answer, it sometimes creates unintentional situations. – blackened Sep 11 '15 at 17:13