Skip to content

Instantly share code, notes, and snippets.

@serthy
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serthy/cfd3a53e21668aa18897 to your computer and use it in GitHub Desktop.
Save serthy/cfd3a53e21668aa18897 to your computer and use it in GitHub Desktop.
:: sumatrapdf.exe is in miktex/miktex/bin
:: biber.exe in miktex/miktex/bin
:: sumatrapdf: einstellungen > optionen : 'pfad/zu/sublime_text.exe %f:%l:100000' eintragen
:: call this batch file like: 'tex.bat myTexFile' (myTexFile without any extension)
@echo off
setlocal
set document=%~n1
set miktexpath=C:/bin/programme/miktex/miktex/bin
set path=%path%;%miktexpath%;
call :deletetemporaries
call :compile
goto final
:compile
echo ! Begin Compilation
call :buildtex
if errorlevel 1 (
call :syntaxerror
) else (
call :buildglossaries
call :buildbib
call :buildtex
call :buildglossaries
call :buildpdf
call :showpdf
call :deletetemporaries
)
:deletetemporaries
echo ! Delete temporaries
del /s *glg >nul 2>&1
del /s *gls >nul 2>&1
del /s *glo >nul 2>&1
del /s *blg >nul 2>&1
del /s *bbl >nul 2>&1
del /s *toc >nul 2>&1
del /s *out >nul 2>&1
del /s *log >nul 2>&1
del /s *lot >nul 2>&1
del /s *lof >nul 2>&1
del /s *ist >nul 2>&1
del /s *bcf >nul 2>&1
del /s *aux >nul 2>&1
del /s *run.xml >nul 2>&1
goto end
:buildglossaries
makeindex -s %document%.ist -t %document%.sym.glg -o %document%.sym.gls %document%.sym.glo 2>nul
makeindex -s %document%.ist -t %document%.acr.glg -o %document%.acr.gls %document%.acr.glo 2>nul
makeindex -s %document%.ist -t %document%.idx.glg -o %document%.idx.gls %document%.idx.glo 2>nul
goto end
:buildpdf
pdflatex -interaction=batchmode -synctex=1 %document%.tex 1>nul
echo.
goto end
:buildtex
pdflatex -interaction=batchmode -draftmode %document%.tex 1>nul
goto end
:buildbib
biber %document% 2>nul
goto end
:syntaxerror
pdflatex -draftmode %document%.tex
echo ! Compilation failed
goto end
:showpdf
SumatraPDF -reuse-instance %document%.pdf 1>nul
goto end
:final
echo ! Compile done
echo.
exit
:end
goto:eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment