pdflatex-makeindex-bibtex 的批处理脚本,适用于记事本中的当前文件++

发布于 2024-12-08 02:07:36 字数 1819 浏览 0 评论 0原文

我编写了一个批处理文件,用于创建一个包含乳胶文件中的缩写和引用的文件。它运作得很好。我在记事本++运行菜单中使用它。我的问题是我每次都必须从批处理文件中更改文件名。我想创建一个可以处理任何文件的通用文件。

这是我的工作脚本

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex thesis.tex
bibtex thesis
pdflatex thesis.tex
pdflatex thesis.tex
makeindex.exe thesis.nlo -s nomencl.ist -o thesis.nls
pdflatex thesis.tex
START "" thesis.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

,这是我的尝试

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2
bibtex thesis
pdflatex %2
pdflatex %2
makeindex.exe thesis.nlo -s nomencl.ist -o thesis.nls
pdflatex %2
START "" %2.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

,但正如您所看到的,bibtex 和 makeindex.exe 命令行存在挑战,因为不应向 bibtex 提供扩展名,因此 %2 指的是当前在记事本++中打开的文件将不起作用。我也不知道如何指定全局 .nlo 和 .nls 以便 mnakeindex 可以找到与 tex 文件名相对应的正确文件名。

我从记事本++批量执行此操作,因为我无法使用文本生成命名法!

感谢您的帮助

事实证明,将批处理文件中出现的所有thesis 替换为%2 确实有效。我想我问得太早了,但如果有人有类似的问题,这里是解决方案:

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2.tex
bibtex %2
pdflatex %2.tex
pdflatex %2.tex
makeindex.exe %2.nlo -s nomencl.ist -o %2.nls
pdflatex %2.tex
START "" %2.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

I have written a batch file that I use to create a file containing abbreviations and references from a latex file. It works very well. I use this from within notepad++ Run menu. My problem is that I have to change the filename from within the batch file every time. I would like to create a universal file that can work with any file.

here is my working script

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex thesis.tex
bibtex thesis
pdflatex thesis.tex
pdflatex thesis.tex
makeindex.exe thesis.nlo -s nomencl.ist -o thesis.nls
pdflatex thesis.tex
START "" thesis.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

and here is my attempt

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2
bibtex thesis
pdflatex %2
pdflatex %2
makeindex.exe thesis.nlo -s nomencl.ist -o thesis.nls
pdflatex %2
START "" %2.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

but as you can see there is a challenge with the bibtex and the makeindex.exe command lines because an extension is not supposed to be provided to the bibtex and so the %2 which refers to the current opened file in notepad ++ wont work. I also dont know how to specify global .nlo and .nls so that mnakeindex can find the right filenames corresponding to the tex filename.

I am doing this by batch from notepad++ because i failed to generate nomenclature using textworks!!

Thanks for any help

It turns out that replacing all the incidences of thesis in the batch file to %2 actually works. I guess i asked too early but if anyone has a similar problem here is the solution:

:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
%~d1
cd %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2.tex
bibtex %2
pdflatex %2.tex
pdflatex %2.tex
makeindex.exe %2.nlo -s nomencl.ist -o %2.nls
pdflatex %2.tex
START "" %2.pdf

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨与橙与城 2024-12-15 02:07:36

我知道您已经有了解决方案,但还有另一种方法。

只需使用命令“basename”即可删除结尾。

在批处理文件中包含该行

filebase=$(basename $2 .pdf)

,然后“filebase”将是“thesis”,即使您输入“thesis.pdf”(根据需要替换 $2)。

I realize that you already have the solution, but there is another way.

Just use the command "basename" to remove the ending.

Include the line

filebase=$(basename $2 .pdf)

in your batch file and then "filebase" will be "thesis" even if you give as input "thesis.pdf" (replace $2 as appropriate).

风流物 2024-12-15 02:07:36
:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
PUSHD %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2.tex
bibtex %2
pdflatex %2.tex
pdflatex %2.tex
makeindex.exe %2.nlo -s nomencl.ist -o %2.nls
pdflatex %2.tex
START "" %2.pdf
call:cleanup
goto:eof

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof
:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"

:: Change Drive and  to File Directory
PUSHD %1

:: Run Cleanup
call:cleanup
tskill acrobat  
pdflatex %2.tex
bibtex %2
pdflatex %2.tex
pdflatex %2.tex
makeindex.exe %2.nlo -s nomencl.ist -o %2.nls
pdflatex %2.tex
START "" %2.pdf
call:cleanup
goto:eof

:cleanup
:: del *.log
del *.dvi
del *.aux
del *.bbl
del *.blg
del *.brf
del *.out
goto:eof
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文