2

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.

Stefan Pinnow
  • 29,535
clf maris
  • 129
  • 2
  • 10
  • 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 08:16
  • 6
    I found that command in this answer: http://tex.stackexchange.com/questions/187672/path-for-saving-pdf-in-texstudio – 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 http://stackoverflow.com -- {batch-file} is the tag to look for). – alwaysask Aug 10 '16 at 19:58
  • thank you for your help; i wrote a simple java app which is called every time i compile the .tex file and i set the source and the destination path in the main.tex as @alwaysask suggested – clf maris Aug 12 '16 at 19:02

1 Answers1

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.

Diaa
  • 9,599