开发者

batch script for pdflatex-makeindex-bibtex that works on current file in notepad++

开发者 https://www.devze.com 2023-04-11 09:42 出处:网络
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 h

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


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).


:: 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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号