2

This question already has an answer here:

I'm using TeXstudio and I defined my command to copy the generated PDF into another directory:

cmd /C copy %.pdf C:\Users\me\myLatex\pdf

and all works fine.

Now I would like to specify the output path into the .tex file; namely, I would like to do this:

cmd /C copy %.pdf outputDirectory

and in the TEX file something like (the following line does not make sense, is just to explain what I want to do):

\define outputDirectory = C:\Users\me\myLatex\pdf 

in order to specify different output path for each document.

marked as duplicate by Stefan Pinnow, egreg, user36296, Zarko, barbara beeton Aug 11 '16 at 20:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • It's unclear to me how/where do you use the copy command you defined: as a shell-escape, augmented to TeXstudio build commands or else ... Maybe you can add an MWE as well. – alwaysask Aug 10 '16 at 8:16
  • 6
    I found that command in this answer: tex.stackexchange.com/questions/187672/… – clf maris Aug 10 '16 at 12:56
  • You can place a commented line in your main .tex source -- like for example % outputdirectory = C:\my\preferred\path\for\this\pdf . Then you can create a batch file that takes %.tex as argument, searches in it for a line containing % outputdirectory =, strips the searched string from the result (or similar way to get only the path you set) and passes it to a copy command. Then use the batch file in TeXstudio same as you set the plain copy command. Of course, you need to take care of missing/invalid path, overwriting/renaming. – alwaysask Aug 10 '16 at 14:42
  • @alwaysask, it would be great if you could put an example of simple Tex file and batch file to follow clearly the steps. – Diaa Aug 10 '16 at 19:35
  • @DiaaAbidou Take any of your tex files and add this line, say as the first line, before \documentclass{...}: % outputDirectory = C:\Users\me\myLatex\pdf or any other keyword combination you like. As for the batch file, sorry, can't help because: (1) I don't a have a Windows OS and (2) it's offtopic on this site (try stackoverflow.com -- {batch-file} is the tag to look for). – alwaysask Aug 10 '16 at 19:58
3

Yes, you can specify both PDF and auxiliary files output directories by PDFLatex options.

In MiKTeX manual, you can specify the output directory of your PDF file (through the option --output-directory) in addition to your auxiliary files one (through the option --aux-directory).

You can follow this answer steps to understand where to input these options.

Not the answer you're looking for? Browse other questions tagged or ask your own question.