0

I'm familiar with \PackageError as a way to cause LaTeX to report a custom error message when the command is run. But I'm wondering, is there a way to cause LaTeX to report an error, with a custom filename and location?

I run my .tex files through an external preprocessor, and when that preprocessor fails, I'd like to have my editor (vscode Latex-workshop) report the error inline. My thinking is that, if the preprocessor fails, I can have it generate a "dummy" file that calls PackageError reporting the location of the preprocessing error.

I also use latexmk, so if there's a way to do this using its tools, that would work too.

  • I think the answer to your question is "no". But it is a bit hard to understand so perhaps I misunderstood the question. If you want to generate an error that says it is made on line 100 of foo.tex you could generate a 100 line text file which is blank except for a \PackageError on line 100, but I don't think you mean that? – David Carlisle Mar 25 at 20:41
  • @DavidCarlisle That's what I'm trying to avoid. I'll generate the 100-line file if I have to, but I'd rather a command that says "output the error as if I'd generated a 100 line file". – jmite Mar 25 at 20:54
  • well it depends who or what the error is for, you can of course simply \typeout exactly that message and then throw a \errmessage to cause an error, but you may need to fake tex's format more or less exactly if for example you want an existing editor error log parser to pick it up – David Carlisle Mar 26 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.