During the course of my EngD I have started using LaTeX for writing papers and documents (technically I use MikTeX, but that’s just because I’m on Windows). It’s a bit tricky to get used to, especially as it does some things in an odd way, so I’ve written a handy little script to automate everything.
Firstly the script “compile.bat”:
:: %1 - Path :: %2 - Filename ::D: cd "%1" mkdir %2 :: Set a load of basic variables to make commands easier. set aux= ::-aux-directory="%1\auxfiles" set job=-job-name "%1\%2\%2" set inc=-include-directory "C:\Documents and Settings\<User>\Application Data\MiKTeX\fuzz" set src=-src-specials :: Convert all local .PNG files to .EPS files for easy insertion. Ideally this :: would only convert images which have not already been converted, but I can't :: see how to do that easily with ImageMagick, and that does preclude the :: possibility of changing images and getting the new versions. UPDATE: I now :: move all the .PNG files to the working directory after converting them. :: This means they still exist for editing and you can update the .EPS file by :: copying the .PNG back to the main directory but means that images are :: generally only converted once each. "C:\Program Files\ImageMagick-6.5.9-Q16\mogrify.exe" -format eps *.png :: Move all the .PNG files to the working directory. move /Y *.png %2 :: Compile the first pass in LaTeX. :: Make sure all output files go to the same place and all input files are :: searched for in the same place. "C:\Program Files\MiKTeX 2.8\miktex\bin\latex.exe" %job% %aux% %inc% %src% "%1\%2" :: Compile the references in BiBTeX. "C:\Program Files\MiKTeX 2.8\miktex\bin\bibtex.exe" %aux% %inc% "%1\%2" :: Run LaTeX twice more (who knows why...). "C:\Program Files\MiKTeX 2.8\miktex\bin\latex.exe" %job% %aux% %inc% %src% "%1\%2" "C:\Program Files\MiKTeX 2.8\miktex\bin\latex.exe" %job% %aux% %inc% %src% "%1\%2" :: Create the PDF file. ::"C:\Program Files\MiKTeX 2.8\miktex\bin\pdflatex.exe" %job% %aux% %inc% "%1\%2" :: Create a postscript file. "C:\Program Files\MiKTeX 2.8\miktex\bin\dvips.exe" -Ppdf -o "%1\%2\%2.ps" "%1\%2\%2.dvi" :: Convert to a PDF. "C:\Program Files\MiKTeX 2.8\miktex\bin\ps2pdf.exe" "%1\%2\%2.ps" "%1\%2.pdf" :: View it. "%1\%2.pdf"
Most of the lines are commented, but I’ll go over what it does anyway.
Firstly it reads the directory with your .tex file in and converts all found .PNGs to .EPS, this is because LaTeX can’t use PNGs but I tend to make them. It then moves all the original PNGs to a child directory with the same name as the output file. This allows you to modify the files and reconvert them by putting them back in the parent directory, but saves reconverting the files every time you produce output.
Secondly it generates the .DVI file. There are quite a few lines to this as it is designed to work with Bibliotex, which requires multiple passes over a file to first collect and then fill out the required references.
Finally it generates a .PDF file and opens it for viewing. You could just use the normal DVI viewer, but I don’t.
Note that this is written specifically for my use with the “FUZZ” type, if you don’t want to use this remove the include line. If you do, update the “<User>” part.
I also use Notepad++, in which I have configured “alt+shift+m” to run this command using:
"C:\Documents and Settings\<User>\Application Data\MiKTeX\compile.bat" $(CURRENT_DIRECTORY) $(NAME_PART)
Again, adjust <User> to your user name.
No tags

Author comment by DracoBlue · 31 January, 2010 at 09:54
Hello Alex,
when I started with LaTeX, I created this little post http://dracoblue.net/dev/getting-latex-to-work-on-windows/72/ for instructions to get it working on windows.
Automation: If you edit with TexMaker you may use the “Quick-Build”-Button, which does most of the necessary steps within one rush. But your script is nice for me as Notepad++ fan
!
PNG: If I compile using the pdf2latex option, I don’t need to have the images in .eps format.
I find myself pretty often faced with issues related to latex and am too lazy to blog post about it – I should do that more often!
Kind regards,
Jan
Admin comment by Y_Less · 3 February, 2010 at 16:40
Thanks Jan, TexMaker looks very nice – I’ll have to play about with it some more to get used to it but it seems useful. I also discovered a few problems with that script when I went back to doing Z editing – it works perfectly fine for regular documents, but not when you have custom fonts defined in a given folder, but I didn’t update this one as the problem was fairly unique to the fact that I don’t have admin on the computer I wrote the script on, so had to work around the fact that I couldn’t properly install the new fonts manually.
Kylie Batt · 11 April, 2010 at 20:08
Извините за то, что вмешиваюсь: У меня похожая ситуация. Готов помочь….
It’s a bit tricky to get used to, especially as it does some things in an odd way, so I’ve written a handy little script to automate […….
Kylie Batt · 21 April, 2010 at 10:02
Абсолютно с Вами согласен. Это отличная идея. Готов Вас поддержать….
рынком грузов It’s a bit tricky to get used to, especially as it does some things in an odd way, so I’ve written a handy little script to automate […….
S · 31 May, 2010 at 15:38
Sonya…
Servis…
Video · 3 June, 2010 at 05:39
Обсуждение…
Такой подход обусловлен следующими причинами: http://paradoxxx37.narod.ru/...
Любосмысл · 6 June, 2010 at 17:17
Не хуя себе…. « Играй в S.T.A.L.K.E.R….
Не хуя себе…. « Играй в S.T.A.L.K.E.R. …
Карандаш · 12 June, 2010 at 03:17
С…
.. начиная …..
Бруно · 19 July, 2010 at 23:20
Ворд…
ариф ……
Современная электроника » Blog Archive » Рынок электроники3 · 16 August, 2010 at 18:33
[...] электроники Не надо простых слов, просто пишите в темуРынок электроники Не надо простых слов, просто пишите в темуРынок [...]
Баки · 18 August, 2010 at 02:48
Талон…
прав ……
Ворд · 18 August, 2010 at 12:08
Круп…
моду ……
Крок · 19 August, 2010 at 14:53
Тайм…
ломи ……