
這似乎是重複的multicols 引入的假 [?] 垂直空間,但那裡的解決方案似乎對我不起作用。基本上我想要使用multicols
的情況不是變更介紹文字和清單之間的垂直間距。右側的輸出使用multicols
:
環境後面還有額外的空間multicols
。
筆記:
- 用環境
minipage
來說明問題。我不知道不是相信這是影響額外垂直空間的問題。 - 該
tikz
包已使用僅有的以突顯間距問題。
代碼:
\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}
結果 (2014-08-25)
以下是我從 Frank Mittelbach 的 MWE 獲得的輸出(請注意,以下文本的間距不正確):
\listfiles 的輸出:
我剛剛更新了全部在運行測試之前從 TeXLive2014 取得軟體套件。那麼,我的其中一個軟體包是否已過時,或者 TeXLive2014 版本是否有問題:
*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
答案1
如果將諸如此類的清單itemize
放置在小型頁面的開頭,則省略清單之前的通常垂直間距。
添加multicols
您所做的方式會在itemize
列表周圍產生一個框,就像迷你頁一樣,因此\topsep
不會添加。相反,您看到的是在環境\multicolsep
之前和之後添加的multicol
。
在文章類 (10pt) 中,\topsep
其值為 8pt 加 2pt 減 4pt,而\multicolsep
類似於 12pt 的值解釋了(大部分)所經歷的差異。因此
\setlength\multicolsep{\topsep}
理論上應該可以解決你的問題。
但是,您的範例也顯示了 multicols 處理中的一個故障,該\prevdepth
故障導致環境後 1.9994pt 未對齊(僅發生在「盒裝」模式下,即如果環境出現在小型頁面或類似內容中)。
因此,您現在還需要修補 multicol 內部之一:
\usepackage{etoolbox}
\makeatletter
\patchcmd\page@sofar{\kern-\dimen\tw@ \ifdim\dimen\tw@}
{\kern-\dimen\tw@ \prevdepth\z@ \ifdim\dimen\tw@}
{\typeout{Success!}}{\ERRORpatching}
\makeatother
透過這兩項調整,您應該會看到以下內容:
這裡要求的是完整的 MWE,如果這在您端不起作用,您可能有一個舊版本multicol
,它是在 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}
烏帕特
1.8g中新增了針對此問題的修復multicol
。新版本現已在 CTAN 上發布,並且應該會在幾天內出現在具有更新功能的發行版上(一旦 Heiko 開始提供 tls 軟體包)。
請注意,合適的設定\multicolsep
仍然是必要的(並且始終如此)。