The Wayback Machine - https://web.archive.org/web/20230615103606/https://github.com/doxygen/doxygen/issues/8604
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

Embedded latex images not generated when any error occurs in _formulas.tex when LATEX_BATCHMODE = YES #8604

Closed
Tcenova opened this issue Jun 17, 2021 · 8 comments
Labels

Comments

@Tcenova
Copy link

Tcenova commented Jun 17, 2021

Describe the bug
Latex images are not generated when LATEX_BATCHMODE = YES and there is an error with one of the equations

Expected behavior
Only equations with errors are not generated correctly

To Reproduce
See example here: doxygen_latex_bug.tar.gz

Version
Compiled from source.
1.9.2 (6fc45ba)
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

Additional context
I believe the issue is due to the if statement here:

doxygen/src/formula.cpp

Lines 198 to 205 in 592aaa4

if (Portable::system(latexCmd,args)!=0)
{
err("Problems running latex. Check your installation or look "
"for typos in _formulas.tex and check _formulas.log!\n");
Portable::sysTimerStop();
Dir::setCurrent(oldDir);
return;
}
not taking into account if batchmode is set or not. If batchmode is YES then it seems like it should disregard the return code. Though that seems like it could have issues as well. Possible checking if the dvi file is generated in batchmode rather than the return code? If there is a dvi file then some of the equations must have succeeded.

@albert-github
Copy link
Collaborator

When looking at the debufg output with doxygen -d extcmd we see (on windows systems):

Executing external command `latex -interaction=batchmode _formulas.tex >NUL`

and on linux type systems:

Executing external command `latex -interaction=batchmode _formulas.tex >/dev/null

and when setting LATEX_BATCHMODE=NO this is still the case.

From the documentation:

LATEX_BATCHMODE If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode command
to the generated LATEX files. This will instruct LATEX to keep running if errors occur, instead of asking the
user for help. This option is also used when generating formulas in HTML.
The default value is: NO.
This tag requires that the tag GENERATE_LATEX is set to YES.

The generation of formulas by means of LaTeX is always done in batchmode, otherwise the doxygen generation process would hang on an incorrect formula. The LATEX_BATCHMODE is only for generation of the pdf in the latex directory (so the user can choose to stop at the first error and handle it or continue and scan the log file). The LATEX_BATCHMODE is useful in automatic processes where also a pdf is generated.

Why is the choice for the termination of the generation of the formulas?
All the formulas are in one go converted from the tex version to a dvi file (so latex only has to be invoked only once, a speed issue).
It is not known what will happen in the different stages when we would continue after an error as it is not known what the effect of an error is and what the severity is (the test case looks like to give still reasonable output), the safest is to stop generating the images.

@Tcenova
Copy link
Author

Tcenova commented Jun 18, 2021

Regarding Documentation

This option is also used when generating formulas in HTML.

This statement is confusing if the LATEX_BATCHMODE is not actually used. I see in the code that -interaction=batchmode is passed in, however it looks like it was added only 18 months ago. Maybe an update or clarification is needed?

Regarding error cases
What are the possible outcomes of generating latex equation images?
Seems like they either succeed, or something goes wrong and images are generated incorrectly or error out and do not get generated. Either case is caught with error codes and does not seem to impact the final output other than it might be missing images, images with incorrect formatting, or images out of order if a page in the _formulas.tex is skipped.

I can see how this does not fit all situations, but for projects with many developers it can become difficult to debug doxygen generation on ones own code when others may have an error in a project. Would you consider adding a configuration tag to allow continuing latex formula image generation on errors? For a large percentage of the cases with small latex syntax errors, an output will still be generated, it just may not be what is desired.

Maybe a long term goal could be changing how each equation is linked to a source file in Doxygen rather than page number of the dvi file? Maybe use dvips -i option to split into multiple files based on section with a section named after the Doxygen source name? That way, if a single equation is not rendered and that page is skipped, the indexes do not shift. Though this is probably a low priority issue since it's only useful for debugging.

@albert-github
Copy link
Collaborator

  • Indeed I see in the documentation also the:

    This option is also used when generating formulas in HTML.

    I think when doing the:

    Commit: 10b2b8fc694b60a17ccd2642f3a40c851e33b9da [10b2b8f]
    Date: Wednesday, February 12, 2020 9:08:11 PM
    Improve formula handling and rendering.
    

    it has been forgotten to remove the LATEX_BATCHMODE for the formulas (like I didn't see it when I wrote my initial comment). I don't see any reason anymore to leave this handling in the code / documentation as now always the -interaction=batchmode is used (this makes sense to me for the reasons mentioned in my original comment, when it wouldn't make sense the -interaction=batchmode should be removed again).
    The formulation is not correct either as it would also be used for RTF and Docbook output as well.
    Thanks for pointing this out.

  • Regarding continuing after and error (i.e. still generating the images in subsequent steps). I think that your formulation:

    Either case is caught with error codes and does not seem to impact the final output other than it might be missing images, images with incorrect formatting, or images out of order if a page in the _formulas.tex is skipped.

    is quite correct. The cases like " it might be missing images" would possibly result in formulas at the wrong place (and when not corrected confuse the reader even more than in case the bare LaTeX code is shown. The

    but for projects with many developers it can become difficult to debug doxygen generation on ones own code when others may have an error in a project

    is, in my opinion, not valid, developers should test their code / generated the documentation before committing it (one shouldn't commit code that doesn't compile either. Though sometimes it happens especially when having different systems.). When having an error in a formula it is reasonably easy to locate the problem by means of the _formulas.tex and _formulas.log files even for another developer.

albert-github added a commit to albert-github/doxygen that referenced this issue Jun 18, 2021
The `LATEX_BATCHMODE` setting is not used anymore for formulas since:
```
Commit: 10b2b8f [10b2b8f]
Date: Wednesday, February 12, 2020 9:08:11 PM
Improve formula handling and rendering.
```
but there were still references in the formulas code and in the documentation.
@albert-github
Copy link
Collaborator

Regarding the usage of the usage in the formulas of LATEX_BATCHMODE, I've just pushed a proposed patch, pull request #8606 removing the code / documentation.

@Tcenova
Copy link
Author

Tcenova commented Jun 18, 2021

is, in my opinion, not valid, developers should test their code / generated the documentation before committing it (one shouldn't commit code that doesn't compile either. Though sometimes it happens especially when having different systems.). When having an error in a formula it is reasonably easy to locate the problem by means of the _formulas.tex and _formulas.log files even for another developer.

While I agree if this is an ideal world, in reality this is not always the case. I don't necessarily agree its easy to locate a problem in _formulas.log since latex error logs can be very verbose for small issues. It can also add unnecessary burden to developers to fix all other issues before testing their own. This becomes even more an issue when previous version of Doxygen (I am not sure of the exact version) did not error out in this manor and generated the images even with latex errors. So for a mixed group of developers some may commit small errors not easily caught by eye on their system (where the images are generated with errors) versus a developer were it does not produce any images due to errors. Due to this change in functionality, does it seem unreasonable to add an override of the new functionality and allow generating images with latex errors reported (but default it to the new functionality)?

@SethGower
Copy link

I am also having this issue, and would like to have a switch to allow some errors. I work in a large project (1500+ source files) with ~20 developers, so it isn't always feasible to expect all docs to have proper LaTeX. Especially since there isn't a way to check the LaTeX syntax in the editor.

doxygen added a commit that referenced this issue Aug 11, 2021
issue #8604 `LATEX_BATCHMODE` not used for formulas anymore
@albert-github
Copy link
Collaborator

Code has been integrated in master on GitHub (please don't close the issue as this will be done at the moment of an official release).

@albert-github albert-github added bug fixed but not released Bug is fixed in github, but still needs to make its way to an official release labels Aug 11, 2021
@doxygen
Copy link
Owner

doxygen commented Aug 18, 2021

This issue was previously marked 'fixed but not released',
which means it should be fixed in doxygen version 1.9.2.
Please verify if this is indeed the case. Reopen the
issue if you think it is not fixed and please include any additional information
that you think can be relevant (preferably in the form of a self-contained example).

@doxygen doxygen removed the fixed but not released Bug is fixed in github, but still needs to make its way to an official release label Aug 18, 2021
@doxygen doxygen closed this as completed Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants