@echo off set target=thesis rem Checking for version of cmd.exe if %CMDEXTVERSION%/==/ ( echo Error: This script requieres command interpreter from Windows 2000 or above. goto :eof ) rem Trying to autodetect MiKTeX installation directory if %texmf%/==/ call :getdir HKCU\Software\MiK\MiKTeX\CurrentVersion\MiKTeX "Install Root" texmf if %texmf%/==/ call :getdir HKLM\Software\MiK\MiKTeX\CurrentVersion\MiKTeX "Install Root" texmf if %texmf%/==/ ( echo Error: Unable to find MiKTeX installation directory echo You must set texmf value manually goto :eof ) rem Name of thesis class set clsname=disser set clssrc=%texmf%\tex\latex\%clsname% set clsdir=.\%clsname% rem Name of BibTeX style set bstsrc=%texmf%\bibtex\bst\%clsname% set bstfile=%clsname%.bst rem Cmdline tools set arc=rar set arcflags=a -r -x%target%.pdf -x%target%.prj set tex=%texmf%\miktex\bin\latex set pdftex=%texmf%\miktex\bin\pdflatex set texflags=-src-specials set bibtex=%texmf%\miktex\bin\bibtex8 set bibtexflags=-B -c cp1251 set epstool=%programfiles%\bin\eps\epstool set epstopdf=%texmf%\miktex\bin\epstopdf set pdftodjvu=pdftodjvu set pdftodjvuflags=--dpi=600 --threshold-level=80 --fg-quality=conservative --bg-subsample=3 --quality=65 --convert-links --fg-colors=256 --fg-image-colors=256 set djvuocr=djvubundle set djvuocrflags=--ocr=lang=(Russian,English) set mktexlsr=%texmf%\miktex\bin\mktexlsr.exe set srcfiles=*.* set clfiles=*.bbl *.bak *.aux *.blg *.out *.toc *.log *.dvi *.tmp *.pdf %target%.%arc% set suffix=$$ if %1/==/ ( :make chcp 1251 %tex% %target%.tex %bibtex% %bibtexflags% %target% %tex% %target%.tex %tex% %texflags% %target%.tex goto :eof ) :start if %1/==/ goto :eof if %1/==pdf/ ( :pdf chcp 1251 %pdftex% %target%.tex %bibtex% %bibtexflags% %target% %pdftex% %target%.tex %pdftex% %texflags% %target%.tex goto :eof ) rem Make source distribution if %1/==srcdist/ ( :srcdist if not exist %clsdir% mkdir %clsdir% xcopy %clssrc% %clsdir% /S xcopy %bstsrc%\%bstfile% . /S call :clean %arc% %arcflags% %target%.%arc% %srcfiles% del /s /q %clsdir% rmdir /s /q %clsdir% del /q %bstfile% goto :end ) if %1/==clean/ ( :clean del /s %clfiles% 2> nul if exist %target%.rar del %target%.rar goto :end ) if %1/==cleansvn/ ( :cleansvn del /s .svn 2>nul goto :end ) rem Fix bounding boxes of EPS files if %1/==fixbb/ ( :fixbb for /f "usebackq" %%n in (`dir *.eps /s /b`) do call :fix %%n goto :end :fix echo %1 %epstool% --copy --quiet --bbox %1 %1.%suffix% move %1.%suffix% %1 goto :eof ) rem Convert EPS to PDF if %1/==epstopdf/ ( :epstopdf for /f "usebackq" %%n in (`dir *.eps /s /b`) do call :conv %%n goto :end :conv echo %1 %epstopdf% "%1" goto :eof ) rem Installs requiered packages if %1/==install/ ( :install if not exist %clssrc% md %clssrc% xcopy %clsdir%\ %clssrc%\ /Y rmdir %clsdir% if not exist %bstsrc% md %bstsrc% move %bstfile% %bstsrc% %mktexlsr% goto :end ) rem Start default DVI-viewer if %1/==preview/ ( :preview if not exist %target%.dvi call :make start %target%.dvi goto :end ) rem Convert PDF to DjVu using LizardTech DocumentExpress Enterprise if %1/==djvu/ ( :djvu if not exist %target%.pdf call :pdf %pdftodjvu% %pdftodjvuflags% %target%.pdf goto :end ) rem Create backup if %1/==backup/ ( :backup call :srcdist for /f "usebackq" %%n in (`date`) do move %target%.rar %%n.rar goto :end ) if %1/ neq / (echo Don't know how to make %1 ) :end shift & goto :start :getdir for /f "usebackq tokens=4 skip=2" %%i in (`reg query %1 /v %2`) do set %3=%%i goto :eof