![双列文档中的词汇表跳转页面](https://linux22.com/image/364577/%E5%8F%8C%E5%88%97%E6%96%87%E6%A1%A3%E4%B8%AD%E7%9A%84%E8%AF%8D%E6%B1%87%E8%A1%A8%E8%B7%B3%E8%BD%AC%E9%A1%B5%E9%9D%A2.png)
我在使用软件包时遇到了奇怪的行为glossaries
。如果在使用文档时放置大量条目twocolumn
,有时我会得到未填满的列,词汇表会莫名其妙地跳到下一页。我知道我可以使用不同的词汇表样式来避免这种情况,但这个想法是拥有一个花哨的对齐条目列表。下面您可以找到一个最小的工作示例:
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage[nonumberlist,nogroupskip]{glossaries}
\makeglossary
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\foreach \n in {1,...,30}{\newglossaryentry{x\n}{name=var, description=Dummy entry with a long description}}
\glsaddall
\printglossary[title=Nomenclature,style=super]
\section{More text}
\lipsum[1-10]
\end{document}
答案1
不幸的是,问题源于supertabular
环境确定列中没有足够的空间,从而触发分页符。无需该glossaries
包即可重现此效果。这基本上就是该glossaries
包在幕后所做的事情:
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage[debugshow]{supertabular}
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\section*{Nomenclature}
\begin{supertabular}{lp{.6\hsize}}
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
\end{supertabular}
\section{More text}
\lipsum[1-10]
\end{document}
我使用了debugshow
选项,它允许将supertabular
额外信息写入日志文件。此信息以以下内容开头:
Package supertabular: Starting a new supertabular on input line 16.
Package supertabular: Average line height: 13.0pt on input line 16.
Package supertabular: Stretched line height: 1.0pt on input line 16.
Package supertabular: Calculating height of tabular on first page on input line
16.
Package supertabular: Height of text = 388.97215pt;
(supertabular) Height of page = 384.26657pt on input line 16.
Package supertabular: two column mode on input line 16.
Package supertabular: First column on input line 16.
Package supertabular: Second column on input line 16.
Package supertabular: Available height: -4.70558pt on input line 16.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 16.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 16.
Package supertabular: Height of head: 2.5pt on input line 16.
Package supertabular: Height of tail: 15.5pt on input line 16.
Package supertabular: Maximum height of tabular: -4.70558pt on input line 16.
Package supertabular: Minimum height of tabular: 31.0pt on input line 16.
Package supertabular: starting new page on input line 16.
似乎是节标题导致计算出错。但是,如果在节标题前立即强制分页,则制表内容可以容纳:
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage[debugshow]{supertabular}
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\pagebreak
\section*{Nomenclature}
\begin{supertabular}{lp{.6\hsize}}
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
var & Dummy entry with a long description\\
\end{supertabular}
\section{More text}
\lipsum[1-10]
\end{document}
因此,这似乎是 的某种奇怪的功能supertabular
。同一补丁适用于您的 MWE:
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage[nonumberlist,nogroupskip]{glossaries}
\makeglossaries
\foreach \n in {1,...,30}{\newglossaryentry{x\n}{name=var, description=Dummy entry with a long description}}
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\glsaddall
\pagebreak
\printglossary[title=Nomenclature,style=super]
\section{More text}
\lipsum[1-10]
\end{document}
这有点儿不着边际。我知道您不想改变风格,但有一种替代风格可以产生tabular
类似结果,而无需实际使用tabular
类似环境,您可能需要考虑。例如:
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage[nonumberlist,nogroupskip]{glossaries}
\makeglossaries
\foreach \n in {1,...,30}{\newglossaryentry{x\n}{name=var, description={Dummy entry with a long description, and some more padding}}}
\glsaddall
\glsfindwidesttoplevelname
\renewcommand*{\glstreenamefmt}[1]{#1}
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\printglossary[title=Nomenclature,style=alttree]
\section{More text}
\lipsum[1-10]
\end{document}
名称的可用宽度使用 计算\glsfindwidesttoplevelname
。或者,您可以使用 设置最宽值\glssetwidest
:
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage{pgffor}
\usepackage[nonumberlist,nogroupskip]{glossaries}
\makeglossaries
\foreach \n in {1,...,30}{\newglossaryentry{x\n}{name=var, description={Dummy entry with a long description, and some more padding}}}
\glsaddall
\glssetwidest{XXXXXX}
\renewcommand*{\glstreenamefmt}[1]{#1}
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\printglossary[title=Nomenclature,style=alttree]
\section{More text}
\lipsum[1-10]
\end{document}
MWE 只有同样简短的。使用测试文件(随包提供)name
中的条目可以更清楚地展示样式。example-glossaries-long.tex
glossaries
\documentclass[twocolumn]{article}
\usepackage{lipsum}
\usepackage[nonumberlist,nogroupskip]{glossaries}
\makeglossaries
\loadglsentries{example-glossaries-long}
\glsaddall
\glsfindwidesttoplevelname
\renewcommand*{\glstreenamefmt}[1]{#1}
\begin{document}
\title{Minimal working example of glossaries in twocolumn document using \texttt{super} style and a long list of entries spanning in more than one page and more than one column}
\author{Author}
\maketitle
\begin{abstract}
\lipsum[1-2]
\end{abstract}
\printglossary[title=Nomenclature,style=alttree]
\section{More text}
\lipsum[1-10]
\end{document}
与样式不同tabular
,这允许在描述中间换行,这可能适合您,也可能不适合您。