同时使用 tocloft 和 fontspec 时的间距问题

同时使用 tocloft 和 fontspec 时的间距问题

我正在使用 tocloft 创建一个方程式列表,我认为没有其他方法可以避免使用这个包。

但是,每次将 XeLaTeX 中的 tocloft 和 fontspec 一起使用时,枚举和标题之间的间距都会变得混乱。通常它应该看起来像这样:

10.9  Title
10.10 Title

当这两个包一起使用时,它变成这样:

10.9 Title
10.10Title

我找到了某种解决方法,但它有点糟糕,因为它将间距设置为静态值,它看起来像:

10.9 Title
10.10 Title

这是我的示例,您可以通过运行两次 Xelatex 来测试它:xelatex file.tex & xelatex file.tex

\documentclass[a4paper,oneside,12pt]{report}
\usepackage{amsmath}

% ------------------------------------------------------------------------------

% if activated together with tocloft, the spacings between number and title in every "Table of __" are getting fucked up..
\usepackage{fontspec}

% ------------------------------------------------------------------------------

% TRY THIS

\usepackage[tocloftfix,headline={List of Equations}]{listofequations}

% OR

%\usepackage{tocloft}
%\newcommand{\listofequations}{\text{test}}
%\newcommand{\equationlist}[1]{\text{#1}}

% OR NOTHING

% ------------------------------------------------------------------------------

% Workaround: set space to static value, but looks bad because:
% 10.9 Title
% 10.10 Title

% instead of:
% 10.9   Title
% 10.10  Title

\makeatletter
% \renewcommand{\numberline}[1]{ \@cftbsnum #1\@cftasnum\hspace*{1em}\@cftasnumb }
\makeatother

% ------------------------------------------------------------------------------
\begin{document}

\newpage
\addcontentsline{toc}{chapter}{Table of Contents}
\tableofcontents
\newpage

\newpage
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures

\newpage
\addcontentsline{toc}{chapter}{List of Equations}
\listofequations

% ignore anything below this line -> just filler
% ------------------------------------------------------------------------------

\chapter{Title}
\section{Something}
\section{Another}
\section{Something}
\section{Another}
\section{Something}
\section{Another}
\section{Something}
\section{Another}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\begin{figure}
\caption[ToF]{Full}
\end{figure}
\section{Something}
\section{Another}
\section{Something}
\section{Another}
\section{Another}
\begin{equation}\label{eq:pythagoras}\equationlist{Tesst}
x^2 + y^2 = z^2
\end{equation}
Equation (\ref{eq:pythagoras}) is right there.
\chapter{Title2}
\section{Something}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}
\begin{equation}\equationlist{Test2}
x^2 + y^2 = z^2
\end{equation}

\end{document}

以及自制的listofequations.sty:

%
%   List of Equations Package
%
%   Package by Simon Christmann, Credits to http://www.latex-community.org/forum/viewtopic.php?f=44&t=11649 and Google

% usage: 
%   - \listofequations creates the index
%   - after every \begin{equation} declare name for ToE by \equationlist{text for index page}
%   - for \begin{aligned} and other math use  \equationlisttext after the environment's end
%   - specify your desired headline for this list via \usepackage[headline={Special Headline}]{listofequations}
% ----------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{listofequations}[2013/02/04 List of Equations]


% ----------------------------------------------------------
% Import packages
% ----------------------------------------------------------
\RequirePackage{tocloft}
\RequirePackage{kvoptions}

% ----------------------------------------------------------
% Define Parameters
% ----------------------------------------------------------
\DeclareStringOption[Equations]{headline}[List of Equations]
\DeclareBoolOption[false]{tocloftfix}

\ProcessKeyvalOptions* % process parameters that are created with kvoptions package

% ----------------------------------------------------------------------



\iflistofequations@tocloftfix
    \AtBeginDocument{ \renewcommand\@cftmakeequtitle{\chapter*{\listequationsname}} } % due to a bug in tocloft, style changes from \titleformat are not applied - this is just a workaround not a fix!
\fi

\newcommand{\listequationsname}{\listofequations@headline}
\newlistof{equations}{equ}{\listequationsname}
\newcommand{\equations}[1]{\addcontentsline{equ}{equations}{\protect\numberline{\theequation} #1}\par}
\newcommand{\equationlist}[1]{\text{\equations{#1}}}
\newcommand{\equationlisttext}[1]{\equations{#1}}

或从这里下载:http://ablage.stabentheiner.de/2013-02-05_Archiv.zip

以下是 \listfiles 显示的内容:

 *File List*
  report.cls    2007/10/19 v1.4h Standard LaTeX document class
  size12.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
fontspec.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
   expl3.sty    2013/07/28 v4582 L3 Experimental code bundle wrapper
 l3names.sty    2012/12/07 v4346 L3 Namespace for primitives
l3bootstrap.sty    2013/07/28 v4581 L3 Experimental bootstrap code
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
l3basics.sty    2013/07/28 v4581 L3 Basic definitions
 l3expan.sty    2013/07/24 v4565 L3 Argument expansion
    l3tl.sty    2013/07/28 v4581 L3 Token lists
   l3seq.sty    2013/07/28 v4581 L3 Sequences and stacks
   l3int.sty    2013/07/28 v4581 L3 Integers
 l3quark.sty    2013/07/21 v4564 L3 Quarks
   l3prg.sty    2013/07/28 v4581 L3 Control structures
 l3clist.sty    2013/07/28 v4581 L3 Comma separated lists
 l3token.sty    2013/07/28 v4581 L3 Experimental token manipulation
  l3prop.sty    2013/07/28 v4581 L3 Property lists
   l3msg.sty    2013/07/28 v4581 L3 Messages
  l3file.sty    2013/07/28 v4581 L3 File and I/O operations
  l3skip.sty    2013/07/28 v4581 L3 Dimensions and skips
  l3keys.sty    2013/07/28 v4581 L3 Experimental key-value interfaces
    l3fp.sty    2013/07/09 v4521 L3 Floating points
   l3box.sty    2013/07/28 v4581 L3 Experimental boxes
l3coffins.sty    2012/09/09 v4212 L3 Coffin code layer
 l3color.sty    2012/08/29 v4156 L3 Experimental color support
l3luatex.sty    2013/07/28 v4581 L3 Experimental LuaTeX-specific functions
l3candidates.sty    2013/07/24 v4576 L3 Experimental additions to l3kernel
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
  xparse.sty    2013/07/28 v4582 L3 Experimental document command parser
fontspec-patches.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTe
X
fixltx2e.sty    2006/09/13 v1.1m fixes to LaTeX
fontspec-xetex.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
 fontenc.sty
  eu1enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
  eu1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
 eu1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 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
   xetex.def    2013/04/29 v0.96 LaTeX color/graphics driver for XeTeX (RRM/JK)

fontspec.cfg
listofequations.sty    2013/02/04 List of Equations
 tocloft.sty    2013/05/02 v2.3f parameterised ToC, etc., typesetting
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
 amsmath.sty    2013/01/14 v2.14 AMS math features
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
  amsbsy.sty    1999/11/29 v1.2d
  amsopn.sty    1999/12/14 v2.01 operator names
   t3cmr.fd    2001/12/31 TIPA font definitions
 ***********

答案1

问题在于标签所占的空间大小。如果你跟踪代码,你会发现 \cftsecnumwidth设置为 23pt,而\cftequationsnumwidth仅为 15pt。想必这些应该相同:

\setlength{\cftequationsnumwidth}{\cftsecnumwidth}

装完各个包之后就可以了。

相关内容