3

I use vs code for writing and compiling tex files.

I changed on vs-code settings the Out Dir to the folder: %DIR%/build.

vs-code outdir

With this setting all the auxiliary files and the pdf are saved in ./build but I would like the pdf to be saved in the same directory as the tex file, not in ./build.

Is there any option to do so?? Thanks in advance

5
  • Can you please edit your question and provide more background information for the first-time reader? E.g. I have no idea, what your situation is, and how much it might be related to Latex, i.e. the topic of this group. Thanks
    – MS-SPO
    Commented Sep 14, 2021 at 11:52
  • @MS-SPO I edited the question, better now?
    – Pablo
    Commented Sep 15, 2021 at 11:08
  • Thanks. You'll know by the answers. But I fear, unless I'd be a pro in using Latex with VisualStudio , probably not. Consider us being sort of blind wrt. your place, what you configured and what you didn't, which versions you use, what's behind your build-path etc. // BTW, did you click on your tag [visual-sutio-code] to check for similar questions?
    – MS-SPO
    Commented Sep 15, 2021 at 12:13
  • Thanks @MS-SPO. I realized that if there is a way to do so it is just too complicated to do. It is just easier to move it manually. Should I leave the question open in case someone knows an easy way to do it??
    – Pablo
    Commented Sep 16, 2021 at 15:44
  • Good question. What you can do is to click on "Flag", ask for moderator intervention and briefly describe, e.g. request deletion. As it is, the question is pretty premature ;-) Enjoy Latex.
    – MS-SPO
    Commented Sep 16, 2021 at 16:11

1 Answer 1

3

According to the documentation found here https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes, it is possible to customize the command line instructions that are done during the build. So we can take the default example and add an instruction to it to copy the pdf file into the main directory.

In a settings.json file you can add:

  "latex-workshop.latex.tools": [ // list of tools to be used by recipes
    {
      "name": "latexmk",
      "command": "latexmk",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "-pdf",
        "-outdir=%OUTDIR%",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "pdflatex",
      "command": "pdflatex",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "bibtex",
      "command": "bibtex",
      "args": ["%DOCFILE%"],
      "env": {}
    },
    {
      "name": "pdf windows",
      "command": "copy",
      "args": ["%OUTDIR_W32%\\%DOCFILE%.pdf", "%DIR_W32%\\"]
    },
    {
      "name": "pdf linux & mac",
      "command": "cp",
      "args": ["%OUTDIR%/%DOCFILE%.pdf", "%DIR%/"]
    }
  ],

  "latex-workshop.latex.recipes": [
    {
      "name": "latexmk",
      "tools": ["latexmk", "pdf windows"] // or "pdf linux & mac" if you are on linux or mac
    },
    {
      "name": "pdflatex -> bibtex -> pdflatex * 2",
      "tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex", "pdf windows"] // or "pdf linux & mac" if you are on linux or mac
    }
  ],

Be careful to change "pdf windows" by "pdf linux & mac" if you are not on windows. Since we're just taking the default example and not modifying any files (hence the copying) there shouldn't be any problems.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .