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

Read PDF path from .latexmkrc #3860

Open
anwaralameddin opened this issue Oct 29, 2024 · 0 comments
Open

Read PDF path from .latexmkrc #3860

anwaralameddin opened this issue Oct 29, 2024 · 0 comments

Comments

@anwaralameddin
Copy link

anwaralameddin commented Oct 29, 2024

Describe the feature and the current behavior/state

Currently, the TeXstudio internal viewer expects the generated PDF path to be the same as the source $\TeX$ document, except for the file extension. It would be useful if it could instead read the PDF path from the .latexmkrc file if it exists, as it could be different when using latexmk. The requested feature only applies if the meta-command Default Compiler is set to txs:///latexmk.

As far as I can see, currently, one can only override this path on a case-by-case basis, which requires changing settings when switching between projects, and it would be useful if this could be automated.

Who will benefit from this feature?

My primary goal here is to be able to build the document while keeping the project root directory relatively tidy. For this, I am using latexmk with a .latexmkrc file in the project root directory. In the .latexmkrc file, I am using the configuration variables $aux_dir (to specify a directory for .aux, .bbl, .blg, .log, .out... files), $out_dir (to specify a directory for .pdf and .synctex.gz), $jobname (to specify the generated artefacts base name) and $do_cd (to specify whether to cd to the main source directory before processing). More information about these variables can be found in the manual on pages 30, 45, 41 and 36, respectively.

Any Other info

Starting with the default settings, I have set the command Latexmk to the full path of the latexmk executable and set the meta-command Default Compiler to txs:///latexmk. Then, compiling a main.tex file succeeds, and the generated files have the correct name and are stored in the directories specified in the .latexmkrc file. However, the TeXstudio internal viewer does not display the PDF file and shows the error message:

Failed to find file "full/path/to/the/project/root/directory/main.pdf"; perhaps, it has been deleted.

Opening the PDF file using File > Open partially works in the sense that Compile updates the viewer and Go to Source works. However, the Go to PDF, View and Build and View commands remove the PDF from the viewer and result in the above error message.

The issue could be reproduced using the main.tex document:

\documentclass{amsart}
\begin{document}
  Example
\end{document}

and the .latexmkrc file:

$aux_dir = ".aux";
$do_cd = 1;
$jobname = "Project Name";
$out_dir = "output";
$pdf_mode = 1;
$pdflatex = "pdflatex -synctex=1 -interaction=nonstopmode -file-line-error" .
  "%O %S";
$show_time = 1;
$warnings_as_errors = 1;

It is not clear to me whether latexmk could report the generated PDF location in a 'dry run', but it could specify the location of the rc file it uses, if any, using the command:

latexmk -rc-report

A different issue is that, when compiling with the command txs:///latexmk, TeXstudio Log is empty, and TeXstudio Messages are too brief compared to latexmk output when run on the command line. I could report this as a separate issue if needed.

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