I am trying to create user-defined commands in TeXworks, but am having problems finding the syntax to reference the main .tex file. For instance, creating a .bat-file and then a new "typesetting tool" in TeXworks pointing to that .bat file works fine if the contents is the following line:
pdflatex "mylatexfile.tex"
"mylatexfile.tex" then compiles without problems, and the first line of the compiler output is
C:\mypath>pdflatex "mylatexfile.tex"
The following, however, doesn't work:
pdflatex "%1.tex"
The compiler then starts with the line
C:\mypath>pdflatex ".tex"
and ends with "...File ignored)...". Am I wrong to assume that "%1" references the main latex file? (That's what I understood from http://code.google.com/p/texworks/wiki/AdvancedTypesettingTools#tex_-%3E_dvips_-%3E_ps2pdf.)
In the latex editor LEd, I've successfully created user-defined commands using .bat files. There, however "%2" is supposed to reference the main latex file. I've tried that in TeXworks but to no avail. I get the same result as using "%1".
Any tips?
I'm using MiKTeX 2.9 and Windows 7.



%nvariable expands to the(n+1)th parameter passed in the command line. If you calltest.bat a b c, the pairs will be%0=test.bat,%1=a,%2=band%3=c. My guess is that you are calling yourbatfile without passing the filename, so%1=. Try to call it providing the filename, say,test.bat myfile, so%1.texwill be expanded tomyfile.tex. – Paulo Cereda Dec 8 '11 at 11:00