5
-Main Directory
  - sub direcory
      -xx.tex
  - sub directory
      -yy.tex

I am trying to create pdf file for all latex files, but it only works if I am in sub directory folder

example C:Users/Desktop/MainDirectory>sub directory latexmk -pdf I will get xx.pdf file

However if I did C:Users/Desktop/MainDirectory> latexmk -pdf I will get error, saying No file name specified, and I couldn't find any

mtkilic
  • 1,213
  • 1
  • 12
  • 28
  • 1
    That makes sense. By default `latexmk` compiles all *.tex files in the current directory. Your only option is to create a main *.tex file within the main directory. – mforpe Apr 26 '17 at 21:43

1 Answers1

2

latexmk -pdf will look for a .tex file in your current directory. If it doesn't find any in the current directory, it doesn't recursively search for them anywhere else. After all, how does it know whether it should compile xx.tex or yy.tex, or how deep it should go?

You can provide a filename to it, though, telling it what file to compile, as latexmk -pdf subdir1/xx.tex, and it will output the files in the current working directory.

Note: this is probably not the best practice, you might as well go into subdir1 and run the same command (latexmk -pdf xx.tex) with the output-directory=.. command. I don't know why you would want all your tex compiles in the same folder, though, and separate the source codes.

On another note, while I see you're using Windows, you could recursively run all your texfiles in subdirs with the find command in Linux, as this: find . -name *.tex -exec latexmk -pdf {} \;. This might lead to issues if some texfiles have the same name. Omit the trailing -exec... to run a dry-run to see which files you want.

mazunki
  • 682
  • 5
  • 17