Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic build_dir #2137

Closed
habamax opened this issue Aug 19, 2021 · 13 comments
Closed

dynamic build_dir #2137

habamax opened this issue Aug 19, 2021 · 13 comments

Comments

@habamax
Copy link
Contributor

habamax commented Aug 19, 2021

Is your feature request related to a problem? Please describe it.

I would like to have only tex and pdf files to be in the end in the filesystem.
Unfortnunately VimtexClean does nothing for me.
I was thinking if I can at least hide all generated files into some sub folder - it would kind of solve my issue.
Now there is a build_dir I can try to use but it is static and I couldn't find a way to make it "per file"

let g:vimtex_compiler_latexmk = {
            \ 'build_dir': './current_tex_basename_folder',  <--------- here I would like to have either `%:t:r` or ` {-> expand("%:t:r")}`
            \ 'options' : [
                \   '-shell-escape',
                \   '-verbose',
                \   '-file-line-error',
                \   '-synctex=1',
                \   '-interaction=nonstopmode',
                \ ],
                \}

Describe the solution you'd like
It would be nice to be able to provide tex file base name as a build-dir for example as a lambda:

let g:vimtex_compiler_latexmk = {
            \ 'build_dir': {-> expand("%:t:r")}
            \ 'options' : [
                \   '-shell-escape',
                \   '-verbose',
                \   '-file-line-error',
                \   '-synctex=1',
                \   '-interaction=nonstopmode',
                \ ],
                \}

Then when I compile tex file test.tex, all aux files are next to it in the test folder.

@lervag
Copy link
Owner

lervag commented Aug 19, 2021

It should not be hard to implement, but I'm curious, why is not using a static name sufficient? Do you keep a lot of documents in the same folder?

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

Do you keep a lot of documents in the same folder?

Yep, that is the case. They are all related, but should be in a separate docs, so I keep them in the same dir.

lervag added a commit that referenced this issue Aug 19, 2021
@lervag
Copy link
Owner

lervag commented Aug 19, 2021

Ok, this should work now. I'll push an update to the docs as well.

@lervag lervag closed this as completed Aug 19, 2021
lervag added a commit that referenced this issue Aug 19, 2021
@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

Thanks. Works if there is no minted package.

Otherwise it errors:
image

and the output pdf has no code that is in minted environments:
image

Minted helper dir is outside of build_dir if that matters:
image

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

with default build_dir minted is ok as before:
image

@lervag
Copy link
Owner

lervag commented Aug 19, 2021

Thanks. Works if there is no minted package.

Can you give a minimal LaTeX file? It might be a limitation posed by minted itself.

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

yes, probably minted and how it processes their own generated files.

image

\documentclass{article}
\usepackage{minted}

\title{Test Minted}
\author{habamax}

\begin{document}

\begin{minted}{python}
def hello(world):
    pass
\end{minted}

\end{document}

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

And vimtex settings I have:

let g:vimtex_compiler_latexrun_engines = {'_': 'lualatex'}
let g:vimtex_compiler_latexmk_engines = {'_': '-lualatex'}
let g:vimtex_compiler_latexmk = {
            \ 'build_dir': {-> expand("%:t:r")},
            \ 'options' : [
                \   '-shell-escape',
                \   '-verbose',
                \   '-file-line-error',
                \   '-synctex=1',
                \   '-interaction=nonstopmode',
                \ ],
                \}

PS, for minted you have to have pygmentize installed (pip install pygments)

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

(./_minted-test_minted/default-pyg-prefix.pygstyle)
(./_minted-test_minted/default.pygstyle)Error: cannot read infile: [Errno 2] No such file or directory: 'test_minted.pyg'
system returned with code 1


! Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.

Looks like I have to specify it in a package settings?

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

So, yes this is minted related and has nothing to do with vimtex.

@habamax
Copy link
Contributor Author

habamax commented Aug 19, 2021

For future curious ones, this works:

\documentclass{article}

\usepackage{ifthen}
\usepackage{currfile-abspath}
\getabspath{\jobname.log}
\ifthenelse{\equal{\theabsdir}{\thepwd}}% using ifthen package
%\ifdefstrequal{\theabsdir}{\thepwd}% using etoolbox package
    {}{\PassOptionsToPackage{outputdir=\theabsdir}{minted}}
\usepackage{minted}

\title{Test Minted}
\author{habamax}

\begin{document}

\begin{minted}{python}
def hello(world):
    pass
\end{minted}

\end{document}

@lervag
Copy link
Owner

lervag commented Aug 19, 2021

Great, I'm glad to see you found a workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants