3

How can I get consistent spacing before and after an itemize environment inside a multicols environment when the list is immediately after or immediately before the start of a section?

enter image description here

The list in Foo2 is an enumitem list and the spacing before and after the list seems to match the spacing before and after the text in Foo1.

The list in Foo3 is the same enumitem list but enclosed in a multicols environment. There is way too much vertical space before and after the two-column list.

The list in Foo4 is the same as Foo3 except \multicolsep is set to 0pt. The space before is still too much but not as bad, and there is now too little space after the list.

How do I fix this to get consistent spacing?

Here's the code:

\documentclass{article}
\usepackage{calc}
\usepackage[vmargin=1em,hmargin=0.25in+1em,papersize={2in,2.7in}]{geometry}

\usepackage{titlesec}
\titleformat{\section}[block]{\normalfont\large\scshape}{}{0pt}{}[\titlerule]
\titlespacing*{\section}{-0.25in}{*0.25}{*0.25}[-0.25in]

\usepackage{multicol}
\usepackage{enumitem}
\SetEnumitemKey{twocol}{
  before=\raggedcolumns\begin{multicols}{2},
  after=\end{multicols},
}
\SetEnumitemKey{twocol0}{
  before=\raggedcolumns\setlength{\multicolsep}{0pt}\begin{multicols}{2},
  after=\end{multicols},
}
\setlist[itemize]{leftmargin=*,nosep,}

\begin{document}%
\section{Foo1}Aj%
\section{Foo2}\begin{itemize}\item{}Aj\end{itemize}%
\section{Foo3}\begin{itemize}[twocol,]\item{}Aj\item{}Aj\end{itemize}%
\section{Foo4}\begin{itemize}[twocol0,]\item{}Aj\item{}Aj\end{itemize}%
\section{Foo5}Aj%
\end{document}

Versions:

  • multicol 2014/08/24 v1.8g multicolumn formatting (FMi)
  • enumitem 2011/09/28 v3.5.2 Customized lists

1 Answer 1

1

If you need multicolumn only to have an on line itemize environment, I suggest another approach, based on the shortlst package. You'll find it on CTAN, but it's not in any distribution for licensing reasons.

I define a tabitemize environment, for column-wise displayed items; the number of columns is controlled by an nc key (3 by default). I think the following code gives what you want:

\documentclass{article}
\usepackage{calc}
\usepackage[vmargin=1em,hmargin=0.25in+1em,papersize={2in,2.7in}]{geometry}

\usepackage{titlesec}
\titleformat{\section}[block]{\normalfont\large\scshape}{}{0pt}{}[\titlerule]
\titlespacing*{\section}{-0.25in}{*0.25}{*0.25}[-0.25in]

\usepackage{multicol}
\usepackage[inline]{enumitem}
\SetEnumitemKey{twocol}{
  before=\raggedcolumns\begin{multicols}{2},
  after=\end{multicols},
}
\SetEnumitemKey{twocol0}{
  before=\raggedcolumns\setlength{\multicolsep}{0pt}\begin{multicols}{2},
  after=\end{multicols},
}
\setlist[itemize]{leftmargin=*,nosep,}


    \usepackage{shortlst, xkeyval}

    \makeatletter
    \newcounter{ncol}
    \define@key{mcl}{nc}[3]{\setcounter{ncol}{#1}}%% 3 columns by default
    \newenvironment{tabitemize}[1][]{%
    \setkeys{mcl}{nc,#1}
    \settowidth{\labelwidth}{\textbullet}
    \setlength{\leftmargini}{\dimexpr\labelwidth+\labelsep\relax}%[1][3]
    \setlength{\shortitemwidth}{\dimexpr\linewidth/\value{ncol}-\labelwidth-2\labelsep\relax}%
          \begin{shortitemize}}%
    {\end{shortitemize}
     \vspace*{\dimexpr-\topsep-\partopsep\relax
     }%

\begin{document}%

\section{Foo1}Aj%
\section{Foo2}\begin{itemize}\item{}Aj\end{itemize}%
\section{Foo3}\begin{tabitemize}[nc = 2]\item{}Aj\item{}Aj\end{tabitemize}%
\section{Foo4}\begin{tabitemize}[nc = 2]\item{}Aj\item{}Aj\end{tabitemize}%
\section{Foo5}Aj%

\end{document} 

enter image description here

4
  • Thank you for your answer. This is closer to what I want, but it looks like there's still extra whitespace after the multicolumn list, and I lose all of the nifty enumitem features. Sep 28, 2014 at 19:45
  • @Richard Hansen: Unfortunately there is no equivalent to shortitemize/enumerate in enumitem. I modified the code to remove the vertical spacing after the list. See my updated answer.
    – Bernard
    Sep 28, 2014 at 21:01
  • +1 thanks for fixing the trailing space. I'm curious as to why that negative space is required. What's adding it? Sep 30, 2014 at 2:28
  • @Richard Hansen: I don't know the details of LaTeX internals, but the definition of shortitemize ends with \endlist, so I suspected this might add the classical vertical spacing at the end of ordinary lists. I tested, and it worked…
    – Bernard
    Sep 30, 2014 at 7:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .