Closed hundith closed 2 years ago
I should have said "I set the default app for opening .tex files to be pdflatex.exe" in the second paragraph. In practice I would do this for an extension different from .tex so as the preserve the normal usage of .tex files.
Thank you for your suggestion. I think it is already possible to achieve this with existing options:
-job-name=NAME Set the job name and hence the name(s) of the output file(s).
-output-directory=DIR Use DIR as the directory to write output files to.
Yes, thank you, that is correct but unfortunately all I can do from my app is LaunchFileAsync the .tex file. At that stage Windows takes over and performs Open With so that pdflatex.exe opens the .tex; there is no way of setting any options on it.
I had wondered whether to suggest it could be useful to have a way of setting a set of default options to be applied when pdflatex.exe is called with none, but I am not confident that this would solve the sandboxing problem. I left the following aspect out of my original posting to keep it simple: When I got the message "I can't write on file `mol000.log'. Please type another transcript file name", I pasted in the full path of that same log file and, to my surprise, this was accepted and indeed the file was written normally. However I when got the same error for "mol000.aux", this time no answer was acceptable. I never got to the .pdf file so I don't know what happens there.
I don't know what the error code 13 means, nor whether it relates to my app's permissions or to pdflatex's or both because I do not know what thread pdflatex is running on. All I can say that I must call LaunchFileAsync on a UI Thread, otherwise I get an exception. But given that pdflatex can write pdflatex.log in response to that launch, then it must be able to write to other fixed name files in the same folder, as long as that involves no references to other paths that might be suspect.
Hello Christian,
Thank you very much for your very prompt response to my proposal. This was the first time I have contributed to a GitHub forum and I wasn't sure of the etiquette, so I posted up my reply there. But I welcome this chance to email you directly as there are other aspects that I would like to discuss.
As you say, it is easy to select output paths when running pdflatex from the command line or PowerShell. but that does not help because launching pdflatex directly from my UWP app is prohibited and launching it indirectly does not allow me to specify any options and fails because pdflatex cannot write some of the output files.
I think I may have confused things by presenting the evidence and discussing alternatives, so today I want to put forward a precise proposal, one that will involve no more than 50 lines of code and will make all the difference to the capability of my app.
The starting condition is that I have a small LaTeX file, foo.mol, on disk; double clicking will cause it to Open With pdflatex.exe and that works perfectly to give the .pdf. But launching that same file from my app as a rapid automatic process, pdflatex reports a fatal error. So this is what I need:
If that error occurs when the process was started by 'sihost' and / or the input file extension is '.mol': for the .log file, do nothing, just continue; for the .aux file, also do nothing, just continue (see P.S.); for the .pdf file, write it to a fixed name file ...\AppData\Local\MiKTeX\miktex\log\output.pdf, or, if that does not work, into pdflatex.log is already being being written, I can easily access it from there. Should any LaTeX errors occur in the file, the black window will show them in the normal way, which is exactly what we want.
I propose to send you a simple one screen version of my app, so that you can see what is happening and test out the solution. I would send both the full source code and the app at a msix package for sideloading. Given the holiday period and outstanding marking work, I could do this by about mid January.
I very much appreciate your interest in my proposal and I should like to offer a donation to cover your time and costs; please suggest an appropriate level if you wish.
Best wishes for the Festive Season. Jim Williamson (hundith, which is my middle name)
P.S. Of course I know that the .aux file is essential for handling cross references etc., but those situations are not relevant to my proposal. My fellow tutors ask me for rapid automatic access to pdflatex for small rich text comment boxes on the student's script. Most of these comments are very short, for instance "good work" or "not sin but cos"; about 10% of them involve LaTeX for say a single fraction or an integral. For the 1 in a 1000 cases that would involve a .aux file, my colleagues would expect to access pdflatex directly as they have been doing for years; they just want to speed up the vast majority of tiny LaTeX comments.
On 12 Dec 21, at 11:22, Christian Schenk @.**@.>> wrote:
Thank you for your suggestion. I think it is already possible to achieve this with existing options:
-job-name=NAME Set the job name and hence the name(s) of the output file(s). -output-directory=DIR Use DIR as the directory to write output files to.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MiKTeX/miktex/issues/997#issuecomment-991879619, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AW4HJOCDRCTUVKB7XDL6YYDUQSAY3ANCNFSM5J3FLRRA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hello again Christian,
My test app for the automatic pdflatex proposal is ready now and I will post a message on the forum, but I don't know how to make the files available. Perhaps you could advise me on how to do this or upload them on my behalf. They are currently on this link to my DropBox but that link expires on 18th January: https://www.dropbox.com/t/6QUALlMGYkOditG7
I attach some of the files below, they are: README.txt 2 KB Installation of MolLaunchApp.pdf 4.1 MB Mol_Launch_App_1.4.0.0_Test.zip 15.3 MB Mol_Launch_App source.zip 31 KB
I apologise that the installation instructions for the security certificate and the side-loading app itself are quite elementary, but that is the sort of details that I give to my Open University colleagues who use my marking app.
Best wishes Jim
P.S. I am only attaching 2 files because the O.U. does not permit the sending of executable files even in a zip and the PDF is too large for your server.
On 12 Dec 21, at 11:22, Christian Schenk @.**@.>> wrote:
Thank you for your suggestion. I think it is already possible to achieve this with existing options:
-job-name=NAME Set the job name and hence the name(s) of the output file(s). -output-directory=DIR Use DIR as the directory to write output files to.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MiKTeX/miktex/issues/997#issuecomment-991879619, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AW4HJOCDRCTUVKB7XDL6YYDUQSAY3ANCNFSM5J3FLRRA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
How to use MolLaunchApp
Beforehand:
Set the default app for opening .mol files to be pdflatex.exe.
Running this app:
Browse button: choose a folder where you hope the conversion of tex to pdf will take place.
If you wish, make any changes to the sample LaTeX code.
Launch button: pdflatex.exe will process the .mol file.
If the processing completes:
Show button: view the pdf report which folder was successful.
Otherwise:
Note that pdflatex.log is written in the usual way in a folder such as "C:\Users\Jim\AppData\Local\MiKTeX\miktex\log"
Double click the .mol file to verify that pdflatex.exe, when launched manually from that same folder, can process it.
Afterwards:
It is proposed that pdflatex.exe be revised in order to work when launched automatically from an app.
Results so far
In all cases, the app writes the .mol file to the folder and launches it, but pdflatex.exe fails on:
"This is pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.7)
entering extended mode
! I can't write on file `MolLaunchTest.log'.
Please type another transcript file name:"
In all cases, double clicking the .mol file directly runs pdflatex.exe successfully and produces the PDF file.
The app has been tested for the following folders:
general:
C:\
C:\Users\Jim\Desktop
C:\Users\Jim\Documents
C:\Users\Jim\Downloads
the app's local folder:
C:\Users\Jim\AppData\Local\Packages\d471354b-5e29-4f25-9139-b50f2dfc2229_w1z4mjmeyv1vw\LocalState
where pdflatex.log is written:
C:\Users\Jim\AppData\Local\MiKTeX\miktex\log
a USB stick:
D:\
Having downloaded the MikTeX source code and opened it in Visual Studio 2022, I was able to identify the error message "I can't write on file" in the code, so I would be happy to try make the necessary amendments.
However VS started the CMake generation for default configuration: 'x64-Debug' and failed saying "The program cat could not be found." By commenting out lines, I found the first things missing were: cat, diff, sed, xsltproc, pandoc, hhc, fop, BISON REQUIRED, FLEX REQUIRED, pthread.h though others such as msgfmt did not raise an error. Could someone advise me what more needs to be downloaded in order to make this app?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hello Christian,
My proposal has been marked as stale which is fair enough as it has not generated the interest that I expected. I am currently occupied by Open Uni duties, but I hope to get back to the proposal in a few weeks. I have made some progress with CMake for Windows but I am not sure whether it will in the end be successful. So even though launching MikTeX automatically from Windows is the objective, I intend to try the same idea on the Mac, with which I am much more familiar. Having found the similarities and differences and studied your FAQ, I may post again on the forum, say in three months time.
Thanks again for your help so far.
Jim Williamson (hundith)
On 12 Dec 21, at 11:22, Christian Schenk @.**@.>> wrote:
Thank you for your suggestion. I think it is already possible to achieve this with existing options:
-job-name=NAME Set the job name and hence the name(s) of the output file(s). -output-directory=DIR Use DIR as the directory to write output files to.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MiKTeX/miktex/issues/997#issuecomment-991879619, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AW4HJOCDRCTUVKB7XDL6YYDUQSAY3ANCNFSM5J3FLRRA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I should like to be able to launch pdflatex directly from my C# UWP app on Windows 10, but sandboxing does not allow this; the LaunchFileAsync method is prohibited from launching .exe files.
An easy way is to first set the default app for opening .tex files to be my app. I then obtain a Windows.Storage.StorageFile file for my .tex file and call await Windows.System.Launcher.LaunchFileAsync(file). I have experimented with the .tex file in various places and a good one is where the pdflatex.log file gets written, that is at C:\Users\Jim\AppData\Local\MiKTeX\miktex\log.
The black pdflatex window opened but I get a message ! I can't write on file `mol000.log'. Please type another transcript file name: The entry for this in pdflatex.log is 2021-12-04 08:07:04,549Z INFO pdflatex - this process (10232) started by 'sihost' with command line: C:\Users\Jim\AppData\Local\Programs\MikTeX\miktex\bin\x64\pdflatex.exe C:\Users\Jim\AppData\Local\MiKTeX\miktex\log\mol000.tex ...... 2021-12-04 08:07:04,628Z FATAL pdflatex.core - Permission denied: path="mol000.log", modeString="wb" 2021-12-04 08:07:04,628Z FATAL pdflatex.core - Function: _wopen 2021-12-04 08:07:04,628Z FATAL pdflatex.core - Result: 13 2021-12-04 08:07:04,628Z FATAL pdflatex.core - Data: path="mol000.log", modeString="wb"
I know that it works for that same file from the command prompt or a .bat file; the log entry in that case begins 2021-12-04 08:25:34,610Z INFO pdflatex - this process (7032) started by 'explorer' with command line: C:\Users\Jim\AppData\Local\Programs\MikTeX\miktex\bin\x64\pdflatex.exe C:\Users\Jim\AppData\Local\MiKTeX\miktex\log\mol000.tex
I should like to explain the background to my request. I have been a Tutor in the Open University in the UK for 49 years and I teach 3 maths modules. The students submit their work as PDF files and, on an unpaid basis, I have written an app, first on the Mac and now in beta test on Windows, which is available free to other tutors. While I can handle all the Unicode maths symbols directly and can paste in LaTeX derived images from other apps, MikTeX would be a perfect solution, especially if the app could access it automatically.
So my proposal is that a version of pdflatex.exe could be made available which does not give a fatal error for .log, .aux and .pdf files; instead it writes them to fixed name files such as output.pdf in its log folder in the same way as it writes pdflatex.log.
Alternatively no need for a special version if the standard pdflatex.exe is modified to write to fixed locations whenever its input file has a specific extension different from .tex (I would suggest .mol which is the name of my app, itself named after the Maths On Line research exercise in the Open University in 2007 which got me started on all this in the first place).
hundith