Latex-workshop: How to configure the output directory

Created on 15 Apr 2018  路  5Comments  路  Source: James-Yu/LaTeX-Workshop

There are several issues related to the latex-workshop.latex.outputDir setting - #117, #248 and #341.

However, in each case, the solution is "outputDir doesn't do what you expect," and the issue is closed.

This is fair enough and I appreciate that the outputDir setting is used for another intended purpose.

Apologies for the newbie question, but please could a kind reader guide me on how to configure LaTeX Workshop (or one of the other tools) such that the output from "Build LaTeX Project" goes to a directory of my choice (in my case ./out/)? I am sure it's a simple tweak I need to make to some config file somewhere...

Many thanks for your time.

Most helpful comment

After some further playing about, I realised that's what latex-workshop.latex.recipes and latex-workshop.latex.tools are for...

I currently have the following setup for the default (latextmk), which outputs all the files, including the PDF file, to ./out/:

    "latex-workshop.latex.outputDir": "./out/",
    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": [
                "latexmk"
            ]
        }
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-aux-directory=out",
                "-output-directory=out",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-aux-directory=out",
                "-output-directory=out",
                "%DOC%"
            ]
        }
    ]

The keys seem to be the -aux-directory and -output-directory options, although I'm currently unsure which are definitely required and which are currently superfluous...

I'd be interested in some hints or suggestions from someone who knows that they're talking about.

Many thanks.

All 5 comments

After some further playing about, I realised that's what latex-workshop.latex.recipes and latex-workshop.latex.tools are for...

I currently have the following setup for the default (latextmk), which outputs all the files, including the PDF file, to ./out/:

    "latex-workshop.latex.outputDir": "./out/",
    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": [
                "latexmk"
            ]
        }
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-aux-directory=out",
                "-output-directory=out",
                "%DOC%"
            ]
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-aux-directory=out",
                "-output-directory=out",
                "%DOC%"
            ]
        }
    ]

The keys seem to be the -aux-directory and -output-directory options, although I'm currently unsure which are definitely required and which are currently superfluous...

I'd be interested in some hints or suggestions from someone who knows that they're talking about.

Many thanks.

I'm not familiar with either argument, but it seems like -aux-directory is where the auxiliary files will be placed, e.g., .bbl, .aux, .fls files. -output-directory is where the document will be placed, e.g., .pdf, .dvi.

-aux-directory make no sense on Mac, and the aux file can still not be found by the pdflatex.

Here is my config file to solve this problem for reference.

```

it should be set for the external pdf viewer.

"latex-workshop.latex.outDir": "out.nosync",

.........

{
  "name": "pdflatex",
  "command": "pdflatex",
  "args": [
    "-synctex=1",
    "-interaction=nonstopmode",
    "-file-line-error",

output dir

    "-output-directory=out.nosync",

pdflatex on Mac have no -aux-directory command

    "-aux-directory=out.nosync",
    // "-jobname=main.pdf.nosync",
    "%DOC%"
  ]
},
{
  "name": "bibtex",
  "command": "bibtex",
  "args": [

to find the aux file.

    "out.nosync/%DOCFILE%"
  ]
}

Just use the latexmk recipe and set "latex-workshop.latex.outDir": "out.nosync".

Replace out.nosync with %OUTDIR% for a better understanding.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BjoernDaase picture BjoernDaase  路  3Comments

sth4nth picture sth4nth  路  3Comments

mdrozdo picture mdrozdo  路  4Comments

s-ilic picture s-ilic  路  3Comments

dslemusp picture dslemusp  路  4Comments