randy3k / LaTeXBox

A lightweight but deprecated LaTeX Plugin for Sublime Text 3
44 stars 8 forks source link

Build in separate directory #1

Open int3h opened 11 years ago

int3h commented 11 years ago

Awesome plugin, I love it. LaTeXTools and LaTeXing were not cutting it for me, and this plugin seems like the start to a really good alternative.

One feature request I would like to see, though, is support for putting intermediary files (i.e., anything except the .pdf and maybe the .synctex.gz files) into a separate directory,

LaTeXing supports this by default, by building into the "./Output" subdirectory of the .tex file, then copying the .pdf and .synctex.gz files into the source directory on successful build. However, its implementation is buggy. LaTeXing uses the "-outdir=" option of latexmk, but does not 'cd' into the output directory. This means that packages that generate intermediate files and then later read them back during compilation will not be able to find those files when reading them back.

The "-cd" option of latexmk doesn't fix this, as packages will be looking for generated files in "./", and they end up in the output directory.

What you need to do is manually 'cd' to the output directory before executing the latexmk command (which should not use the "-cd" option.) In Python, that just means setting the 'cwd' keyword argument to the output directory when calling subprocess.Popen().

You also need to 'mkdir' (if needed) for the output directory, as well, of course.

Again, great plugin! Looking forward to seeing how it develops.

randy3k commented 11 years ago

Thanks, I will consider it in the near future. Would you mind telling me what OS you are using?

int3h commented 11 years ago

I'm using OS X 10.8.5, with the MacTex 2013a TeX distribution.

randy3k commented 11 years ago

Could you also provide me an example latex file with the packages that you mentioned?

int3h commented 11 years ago

The graphviz package will do it. Just include that package, then add something like \digraph[scale=0.5]{abc}{rankdir=LR; a->b->c;} to your .tex file.

Compiling it with latexmk using both the '-outputdir' and '-cd' options will cause the PDF to have a message stating it couldn't find the .ps file, instead of a graph you wanted. However, if you manually cd to the output directory, then run latexmk with only "-outputdir" (no "-cd"), it will work.

randy3k commented 11 years ago

I don't think cd to the output dir is a good general solution as it may cause a lot more problems for other packages/programs as the working dir is different to the root file dir. For example, bibtex will not work in this case as it fails to find the bib file.

The package tries to run

dot -Tpdf -o abc.pdf abc.dot

while the file is compiling. Since abc.dot is not at the working directory but at the output dir, it fails to convert it to pdf. It is the design problem of the package graphviz. I don't think there is an easy solution.

\documentclass{article}
\usepackage[pdf]{graphviz}
\begin{document}
\digraph[scale=0.5]{abc}{rankdir=LR; a->b->c;}
\end{document}
randy3k commented 11 years ago

I think that keeping the output dir as working dir is the safest option.

jasonhansel commented 9 years ago

If the problem is that there are too many temp files being created, why not have the "Clean auxiliary files" command be run automatically after each build? Unless there's some reason why keeping the temp files around could be useful (which there might well be -- I'm pretty new to LaTeX).

randy3k commented 9 years ago

It would speed up ur next compilation.