通过 cli 问题 makeindex

通过 cli 问题 makeindex

我目前尝试编写自己的构建脚本,因为目前 perl 不是构建多个词汇表的选项(因此没有 makeglossaries)。当我尝试将所有内容打包到一个批处理文件中时,似乎没有调用 makeindex(没有创建 gls 文件)。

tex.bat 不起作用:

@echo off

set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin

start /wait %miktexpath%/pdflatex %document%.tex ^
&& ^
%miktexpath%/makeindex -s %document%.ist -t %document%.glg -o %document%.gls %document%.glo ^
&& ^
%miktexpath%/makeindex -s %document%.ist -t %document%.idx.glg -o %document%.idx.gls %document%.idx.glo ^
&& ^
%miktexpath%/pdflatex %document%.tex ^
&& ^
%miktexpath%/pdflatex %document%.tex ^
&& ^
%miktexpath%/SumatraPDF -reuse-instance %document%.pdf

如果我将每个 makeindex 调用放入多个批处理文件中,它就可以工作。但这比现在更丑陋了。

工作tex.bat:

@echo off

set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin

start /wait %miktexpath%/pdflatex %document%.tex ^
&& ^
call ./gls.bat %document% ^
&& ^
call ./gls_idx.bat %document% ^
&& ^
%miktexpath%/pdflatex %document%.tex ^
&& ^
%miktexpath%/pdflatex %document%.tex ^
&& ^
%miktexpath%/SumatraPDF -reuse-instance %document%.pdf

gls.bat:

@echo off

set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin

%miktexpath%/makeindex -s %document%.ist -t %document%.glg -o %document%.gls %document%.glo

gls_idx.bat:

@echo off

set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin

%miktexpath%/makeindex -s %document%.ist -t %document%.idx.glg -o %document%.idx.gls %document%.idx.glo

为什么会这样?我该如何编写单个构建脚本?

另一件事:当我使用除/等makeindex之外的文件扩展名时也拒绝构建文件。.gls.glo

答案1

约瑟夫·赖特告诉我这是他的方法,它按预期工作:

@echo off

set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin

%miktexpath%/pdflatex -draftmode -interaction=batchmode %document%.tex
if errorlevel 1 (
    echo ! Compilation failed
) else (
    %miktexpath%/makeindex -s %document%.ist -t %document%.glg -o %document%.gls %document%.glo
    %miktexpath%/makeindex -s %document%.ist -t %document%.idx.glg -o %document%.idx.gls %document%.idx.glo
    %miktexpath%/pdflatex -draftmode -interaction=batchmode %document%.tex
    %miktexpath%/pdflatex -draftmode -interaction=batchmode %document%.tex
    %miktexpath%/SumatraPDF -reuse-instance %document%.pdf
)

相关内容