I am trying to write a .bat file for my Windows machine that removes page numbers and converts the pdf to a png file with pdfcrop
and pdftoppm
. The conversion part is not an issue; running latex from the .bat file is what I'm having trouble with. For example if I make a file mycmd.bat
containing
pdflatex '\AtBeginDocument{\pagestyle{empty}}\input{%1}'
and run mycmd bbb
on the file bbb.tex
\documentclass{article}
\begin{document}
some text
\end{document}
then in the terminal I get
C:\Users\<user>\Downloads> mycmd bbb
C:\Users\<user>\Downloads>pdflatex '\AtBeginDocument{\pagestyle{empty}}\input{bbb}'
pdflatex: security risk: running with elevated privileges
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded format=pdflatex.fmt)
restricted \write18 enabled.
entering extended mode
! I can't find file `''.
<to be read again>
\protect
<*> '\AtBeginDocument
{\pagestyle{empty}}\input{bbb}'
(Press Enter to retry, or Control-C to exit)
Please type another input file name:
But if I run the command pdflatex '\AtBeginDocument{\pagestyle{empty}}\input{bbb}'
directly in the terminal then it works fine.
My only guess is that latex has an issue with the percent in %1
from the .bat file. If this is the issue, how can I fix it? If not, what is going wrong?
%1
in quote marks of some form, like"%1"
in your .bat file. If not then hopefully someone knows the answer, might be a good question for superuser if you don't get an answer over here