使用 nomencl 包时命名法不起作用

使用 nomencl 包时命名法不起作用

当我尝试使用一个简单的命名法示例时,例如:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{nomencl}
\makenomenclature

\begin{document}
\mbox{}

\nomenclature{$c$}{Speed of light in a vacuum inertial frame}
\nomenclature{$h$}{Planck constant}

\printnomenclature
\end{document}

它不显示命名法。我认为问题与我的构建器有关。当我构建 .tex 文件时,控制台中显示以下内容:

TraditionalBuilder: Engine: pdflatex. Invoking latexmk... done.

我正在使用 Sublime Text 构建代码。如何添加适当的构建器?

更新:

我正在使用的构建器如下:

# ST2/ST3 compat
from __future__ import print_function
import sublime
if sublime.version() < '3000':
    # we are on ST2 and Python 2.X
    _ST3 = False
else:
    _ST3 = True

from pdfBuilder import PdfBuilder

DEBUG = False

DEFAULT_COMMAND_LATEXMK = ["latexmk", "-cd", "-e", "-f", "-%E",
                    "-interaction=nonstopmode", "-synctex=1"]

DEFAULT_COMMAND_WINDOWS_MIKTEX = ["texify", "-b", "-p", "--engine=%E",
                    "--tex-option=\"--synctex=1\""]


#----------------------------------------------------------------
# TraditionalBuilder class
#
# Implement existing functionality, more or less
# NOTE: move this to a different file, too
#
class TraditionalBuilder(PdfBuilder):

    def __init__(self, tex_root, output, engine, options,
                 tex_directives, builder_settings, platform_settings):
        # Sets the file name parts, plus internal stuff
        super(TraditionalBuilder, self).__init__(tex_root, output, engine,
            options, tex_directives, builder_settings, platform_settings)
        #Now do our own initialization: set our name
        self.name = "Traditional Builder"
        # Display output?
        self.display_log = builder_settings.get("display_log", False)
        # Build command, with reasonable defaults
        plat = sublime.platform()
        # Figure out which distro we are using
        try:
            distro = platform_settings["distro"]
        except KeyError: # default to miktex on windows and texlive elsewhere
            if plat == 'windows':
                distro = "miktex"
            else:
                distro = "texlive"
        if distro in ["miktex", ""]:
            default_command = DEFAULT_COMMAND_WINDOWS_MIKTEX
        else: # osx, linux, windows/texlive, everything else really!
            default_command = DEFAULT_COMMAND_LATEXMK
        self.cmd = builder_settings.get("command", default_command)

    #
    # Very simple here: we yield a single command
    # Only complication is handling custom tex engines
    #
    def commands(self):
        # Print greeting
        self.display("\n\nTraditionalBuilder: ")

        # See if the root file specifies a custom engine
        engine = self.engine
        cmd = self.cmd[:] # Warning! If I omit the [:], cmd points to self.cmd!

        # check if the command even wants the engine selected
        engine_used = False
        for c in cmd:
            if "%E" in c:
                engine_used = True
                break

        texify = cmd[0] == 'texify'
        latexmk = cmd[0] == 'latexmk'

        if not engine_used:
            self.display("Your custom command does not allow the engine to be selected\n\n")
        else:
            self.display("Engine: {0}. ".format(engine))

            if texify:
                # texify's --engine option takes pdftex/xetex/luatex as acceptable values
                engine = engine.replace("la","")
            elif latexmk:
                if "la" not in engine:
                    # latexmk options only supports latex-specific versions
                    engine = {
                        "pdftex": "pdflatex",
                        "xetex": "xelatex",
                        "luatex": "lualatex"
                    }[engine]

            for i, c in enumerate(cmd):
                cmd[i] = c.replace(
                    "-%E", "-" + engine if texify or engine != 'pdflatex' else '-pdf'
                ).replace("%E", engine)

        # handle any options
        if texify or latexmk:
            for option in self.options:
                if texify:
                    cmd.append("--tex-option=\"" + option + "\"")
                else:
                    cmd.append("-latexoption=\"" + option + "\"")

        # texify wants the .tex extension; latexmk doesn't care either way
        yield (cmd + [self.tex_name], "Invoking " + cmd[0] + "... ")

        self.display("done.\n")

        # This is for debugging purposes 
        if self.display_log:
            self.display("\nCommand results:\n")
            self.display(self.out)
            self.display("\n\n")    

答案1

nomencl用来makeindex处理生成的命名法。也就是说,您需要执行以下步骤:

pdflatex niccolo.tex
makeindex niccolo.nlo -s nomencl.ist -o niccolo.nls
pdflatex niccolo.tex

根据编辑器的不同,添加中间makeindex步骤会有很大差异,不幸的是我对 Sublime Text 不熟悉,所以我无法直接帮助你。

然而,它似乎使用latexmk它处理了很多辅助文件,但在这种情况下,它不知道 的nomencl辅助文件。幸运的是,我们可以通过在 中添加以下几行来告诉它如何处理这些文件.latexmkrc

# Provide support for Nomencl
################################################################################
add_cus_dep('nlo', 'nls', 0, 'run_makenomencl');
push @generated_exts, 'nlo', 'nls';

sub run_makenomencl {
    if ( $silent ) {
        system "makeindex -q '$_[0].nlo' -s nomencl.ist -o '$_[0].nls'";
    }
    else {
        system "makeindex '$_[0].nlo' -s nomencl.ist -o '$_[0].nls'";
    };
}

在您的主目录 ( ) 或与文件相同的目录中查找latexmk该文件( )。如果文件不存在,您需要创建它,请注意,这不是扩展名,而是完整文件名。主目录中的那个将影响 LatexMk 的每次运行(但不会影响其他用户),而 TeX 文件目录中的那个将仅影响该目录中的 LatexMk 运行。.latexmkrc~/.latexmkrc.tex/some/path/.latexmkrc.latexmkrc

一旦添加了这些行(并且可能还创建了文件),通过调用以下命令它就可以正常工作:

latexmk niccolo.tex

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{nomencl}
\makenomenclature

\begin{document}

Let \(c = \hbar = 1\)
\nomenclature{$c$}{Speed of light in any frame}
\nomenclature{$\hbar$}{Reduced Planck constant}

\printnomenclature
\end{document}

输出

相关内容