James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.47k stars 519 forks source link

latexmk enforces pdflatex #4211

Closed BaumiCoder closed 4 months ago

BaumiCoder commented 4 months ago

Pre-checks*

Environment*

The Issue*

The default latexmk tool enforce the compiler pdflatex. This overwrites settings from the .latexmkrc file.

Reproduction Steps

  1. Create a LaTeX document and in the same folder a file .latexmkrc with this content:
    $pdf_mode=4,
    $lualatex='lualatex --shell-escape %O %S'
  2. Use in the latex document something that needs shell escape.
  3. Now you should be able to compile the document with latexmk.
  4. Open it with VSCode and compile it there. The default there is also latexmk and should be triggered by file modifications.

Expected Behavior

Settings from the .latexmkrc file is used, when I use latexmk.

Logs

LaTeX Workshop Output*

Please paste the whole log messages below, not parts of ones. The log should start with New log placeholder %WS1% registered.

[Paste the log here. Do not remove the surrounding backquotes (`).]

Developer Tools Console

Please paste the whole log messages below, not parts of ones. This console logs can sometimes be very important in many cases. To access the log, click Help -> Toggle Developer Tools -> Console.

[Paste the log here. Do not remove the surrounding backquotes (`).]

Anything Else?

The settings for the tools latexmk has an -pdf:

"latex-workshop.latex.tools": [
  {
    "name": "latexmk",
    "command": "latexmk",
    "args": [
      "-synctex=1",
      "-interaction=nonstopmode",
      "-file-line-error",
      "-pdf",
      "-outdir=%OUTDIR%",
      "%DOC%"
    ],
    "env": {}
  },
  //...
]

Manual page for this option:

       -pdf   Generate  pdf  version of document using pdflatex.  (If you wish
              to use lualatex or xelatex, you can use whichever of the options
              -pdflua, -pdfxe, -lualatex or -xelatex applies.)   To  configure
              latexmk  to  have  such  behavior by default, see the section on
              "Configuration/initialization (rc) files".

But also other sources suggest -pdf to make sure to get a pdf file.

jlelong commented 4 months ago

Use the recipe latexmk (latemxkrc) instead. To set the default recipe see https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-workshoplatexrecipedefault

BaumiCoder commented 4 months ago

Use the recipe latexmk (latemxkrc) instead. To set the default recipe see https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-workshoplatexrecipedefault

Right, that works, but is that a solution or only a workaround? The most tools are named as the compiler, but calls them over latexmk. For example:

{
        "name": "lualatexmk",
        "command": "latexmk",
        "args": [
          "-synctex=1",
          "-interaction=nonstopmode",
          "-file-line-error",
          "-lualatex",
          "-outdir=%OUTDIR%",
          "%DOC%"
        ],
        "env": {}
      },

So why the tool latexmk is not called pdflatex? The naming and behavior contradict each other.

And why there is a separate latexmk (latemxkrc) even necessary? How could be there a reason to ignore user and project settings?

James-Yu commented 4 months ago
  1. That is a solution.
  2. Because the command is latexmk, not pdflatex.
  3. We only pass the arguments to latexmk. Whether considering the rc file or not is determined by latexmk, not this extension.