Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating pdf from subdir using latexmk -pdf

Tags:

latex

pdflatex

-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

like image 275
mtkilic Avatar asked Oct 29 '22 08:10

mtkilic


1 Answers

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.

like image 177
mazunki Avatar answered Dec 16 '22 13:12

mazunki