SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 364 forks source link

How to use minted package with latextools? #1439

Closed evandrocoan closed 4 years ago

evandrocoan commented 4 years ago

From https://github.com/gpoore/minted/issues/81 "missing pygments output", we see that minted requires to know where the outputdirectory is.

Then, I can only make it work with LatexTools, by editing my latex code to this:

\usepackage[outputdir={F:\SublimeText\Data\Cache\LaTeXTools\abe5f755bb73246f4f53824425b74d3e}]{minted}
r-stein commented 4 years ago

Is your problem to enable it with the output directory option cached or to enable it in general?

evandrocoan commented 4 years ago

There is a long time I configured LatexTools, so I am not sure. But I can say that this problem only happens when using the pdflatex with some option like --output-directory. For example, if I call pdflatex with --output-directory=/tmp/latex, I must import the minted package with \usepackage[outputdir={/tmp/latex}]{minted}

ig0774 commented 4 years ago

Yeah... that’s why minted has the outputdir option. When you set the —output-directory flag, it changes the location where files are written from within the TeX environment but (afaik) the output directory isn’t made available inside the TeX environment. So if you set —output-directory you’re going to need to set the outputdir option. I’m not sure what LaTeXTools could do here; the behaviour you’re seeing isn’t caused by this package.

evandrocoan commented 4 years ago

LatexTools could use a fixed cache directory. In my project I always import minted with a relative path to my actual project as \usepackage[outputdir={setup/cache}]{minted} because I always have a local directory on my project called setup/cache as I always call pdflatex by hand with --output-directory=setup/cache. Then, if latex tools used my project local relative path cache directory setup/cache, instead of this random cache absolute directory path as ...\Data\Cache\LaTeXTools\abe5f755bb73246f4f53824425b74d3e, then, the problem would be fixed.

ig0774 commented 4 years ago

LaTeXTools output_directory directives support relative paths (from the root file), so you should really just need:

%!TEX output_directory=setup/cache (or the same value as a setting depending on your setup).

evandrocoan commented 4 years ago

Thanks! Problem solved. The same way I set \usepackage[outputdir={setup/cache}]{minted} in my latex source file, I can also set %!TEX output_directory=setup/cache at the top of my main latex source file.