17

This seems to be a duplicate of Spurious [?] vertical space introduced by multicols, but the solution from there does not seen to work for me. Basically I want the case of using multicols to not change the vertical spacing between the intro text and the list. The output on the right is using multicols:

enter image description here

There is also additional space following the multicols environment.

Notes:

  • The minipage environment was used to illustrate the problem. I don not believe that that is affecting the additional vertical space issue.
  • The tikz package is used only to highlight the spacing issue.

Code:

\documentclass{article} 
\usepackage{tikz}
\usepackage{enumitem}

\usepackage{multicol}
\raggedcolumns

%\setlength{\multicolbaselineskip}{0pt}% Seems to have no effect


\begin{document} 
\begin{minipage}[t]{0.44\linewidth}
    The following are examples of numbers:
        \begin{itemize}
            \item 0ne,
            \item $\pi$,
            \item $2+3i$,
            and
            \item $0$.
        \end{itemize}%
    Some text following.
\end{minipage}%
\hfill%-------------------------
\begin{minipage}[t]{0.44\linewidth}
    %% https://tex.stackexchange.com/questions/161966/spurious-vertical-space-introduced-by-multicols
    %\setlength{\topskip}{\fontcharht\font`B }% Seems to have no effect
    The following are examples of numbers:
    \begin{multicols}{2}
        \begin{itemize}
            \item 0ne,
            \item $\pi$,
            \item $2+3i$,
            \item $0$.
            \item Two,
            \item $e$,
            \item $2-3i$,
            and
            \item $-0$.
        \end{itemize}%
    \end{multicols}
    Some text following.
\end{minipage}%
% Following manually tweaked to show the problem.
\begin{tikzpicture}[overlay, remember picture]
    \draw [red]  (-11.5cm,-1.16cm) -- ++(4.8in,0);
    \draw [blue] (-11.5cm,-1.86cm) -- ++(4.8in,0);
    \draw [orange] (-11.5cm,-3.95cm) -- ++(4.8in,0);
\end{tikzpicture}
\end{document} 

Results (2014-08-25)

Here is the output I get from Frank Mittelbach's MWE (note that the spacing for the text following is not correct):

enter image description here

Output from \listfiles:

I just updated all packages from TeXLive2014 prior to running the test. So, is one of my packages out of date, or is there a problem with the TeXLive2014 release:

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
    tikz.sty    2013/12/13 v3.0.0 (rcs-revision 1.142)
     pgf.sty    2013/12/18 v3.0.0 (rcs-revision 1.14)
  pgfrcs.sty    2013/12/20 v3.0.0 (rcs-revision 1.28)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
  pgfrcs.code.tex
 pgfcore.sty    2010/04/11 v3.0.0 (rcs-revision 1.7)
graphicx.sty    2014/04/25 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/05/08 v1.15 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
  pgfsys.sty    2013/11/30 v3.0.0 (rcs-revision 1.47)
  pgfsys.code.tex
pgfsyssoftpath.code.tex    2013/09/09  (rcs-revision 1.9)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
 pgfcore.code.tex
pgfcomp-version-0-65.sty    2007/07/03 v3.0.0 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v3.0.0 (rcs-revision 1.1)
  pgffor.sty    2013/12/13 v3.0.0 (rcs-revision 1.25)
 pgfkeys.sty    
 pgfkeys.code.tex
 pgfmath.sty    
 pgfmath.code.tex
  pgffor.code.tex
    tikz.code.tex
enumitem.sty    2011/09/28 v3.5.2 Customized lists
multicol.sty    2014/04/23 v1.8e multicolumn formatting (FMi)
etoolbox.sty    2011/01/03 v2.1 e-TeX tools for LaTeX
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
supp-pdf.mkii
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
  omscmr.fd    1999/05/25 v2.5h Standard LaTeX font definitions
  • I have managed to put together a hack which inserts a negative \vspace before and after the multicols environment by iterating and guessing at the correct spacing -- but feel that there must be a better way. – Peter Grill Aug 24 '14 at 4:08
12

If a list such as itemize is placed at the start of a minipage its usual vertical spacing before the list is omitted.

Adding multicols the way you did it is producing a box around the itemize list just like a minipage and thus the \topsep is not added. Instead what you see is the \multicolsep which is added before and after the multicol environment.

In article class (10pt) \topsep has the value 8pt plus 2pt minus 4pt while \multicolsep is something like 12pt which accounts for (most) of the differences experienced. Thus

\setlength\multicolsep{\topsep}

should in theory fix your problem.

However, your example also showed a glitch in multicols handling of \prevdepth which accounts for 1.9994pt misalignment after the environment (happens happens only in "boxed" mode i.e. if the environment appears within a minipage or similar).

So additionally you need patch one of the multicol internals for now:

\usepackage{etoolbox}

\makeatletter

\patchcmd\page@sofar{\kern-\dimen\tw@ \ifdim\dimen\tw@}
  {\kern-\dimen\tw@  \prevdepth\z@ \ifdim\dimen\tw@}
  {\typeout{Success!}}{\ERRORpatching}

\makeatother

With those two adjustements you should see the following:

enter image description here

As requested here is the full MWE, if that doesn't work at your end you may have an older version of multicol perhaps, this was run with version 2014/06/19 v1.8f.

\documentclass{article} 
\usepackage{tikz}
\usepackage{enumitem}


\usepackage{multicol}
\raggedcolumns

\usepackage{etoolbox}

\setlength\multicolsep{\topsep}

\makeatletter

\patchcmd\page@sofar{\kern-\dimen\tw@ \ifdim\dimen\tw@}
  {\kern-\dimen\tw@  \prevdepth\z@ \ifdim\dimen\tw@}
  {\typeout{Success!}}{\ERRORpatching}

\makeatother


\begin{document} 
\begin{minipage}[t]{0.44\linewidth}
    The following are examples of numbers:
        \begin{itemize}
            \item 0ne,
            \item $\pi$,
            \item $2+3i$,
            and
            \item $0$.
        \end{itemize}%
    Some text following.
\end{minipage}%
\hfill%-------------------------
\begin{minipage}[t]{0.44\linewidth}
    %% http://tex.stackexchange.com/questions/161966/spurious-vertical-space-introduced-by-multicols
    %\setlength{\topskip}{\fontcharht\font`B }% Seems to have no effect
    The following are examples of numbers:
    \begin{multicols}{2}
        \begin{itemize}
            \item 0ne,
            \item $\pi$,
            \item $2+3i$,
            \item $0$.
            \item Two,
            \item $e$,
            \item $2-3i$,
            and
            \item $-0$.
        \end{itemize}%
    \end{multicols}%
    Some text following.
\end{minipage}%
% Following manually tweaked to show the problem.
\begin{tikzpicture}[overlay, remember picture]
    \draw [red]  (-11.5cm,-1.16cm) -- ++(4.8in,0);
    \draw [blue] (-11.5cm,-1.86cm) -- ++(4.8in,0);
    \draw [orange] (-11.5cm,-3.95cm) -- ++(4.8in,0);
\end{tikzpicture}
\end{document} 

Upate

A fix for this issue was added to multicol 1.8g. The new version is now on CTAN and should show up on distributions with update capabilities in a few days (once Heiko gets around providing the tls package).

Note that a suitable setting for \multicolsep is still necessary (and will always be).

|improve this answer|||||
  • That does not seem to fix the problem for the text following. Can you post the full MWE. In the mean time I am trying to get to the bottom of why we are seeing different results. – Peter Grill Aug 24 '14 at 19:15
  • Oh, and my actual use case is not in a minipage (but within an mdframed) -- just in case that effects things. The minipage was used here just to show the misalignment. – Peter Grill Aug 24 '14 at 21:10
  • I can't see how mdframed would act differently as it too produces a box as I recall. Anyway, you should get at least the same outcome for the MWE as given. – Frank Mittelbach Aug 25 '14 at 6:43
  • I have included the output and package info form \listfiles in the question. Not sure where the problem is. – Peter Grill Aug 25 '14 at 21:52
  • The only noticeable difference is that you use multicol 1.8e while CTAN has 1.8f. And the change long for that version seems relevant: 2014-06-19 Frank Mittelbach <latex-bugs@latex-project.org> * multicol.dtx: color-leak fix introduced a spacing problem in boxed mode as the added color commands were hiding any space at the bottom of the box material (which thus didn't get discarded) – Frank Mittelbach Aug 26 '14 at 6:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.