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
Broken equations #10096
Comments
As you already wrote
I think this might be correct as when I run I do see the things correct and also the Doxygen just creates a tex file and runs some external programs on, you can see these commands by using the debug option I think both the brackets and background color problem are caused by the same problem. |
Is there a way to stop doxygen deleting latex files after completion? |
At the moment this is only possible when you edit the |
Thanks @albert-github ! These are the relevant commands:
So it's There's also As you can see, there's ??. This conversion isn't in the logs. Doxygen has done something to Here is How is |
https://github.com/doxygen/doxygen/blob/master/src/formula.cpp#L429-L465 It is modified here. I will try to debug further. |
@meator The problem with the images with a dark background was that the bounding box was including the background (so basically the whole page was seen as content, not just the formula). This is why we use the bounding box of the formula with the white background (light mode) and apply it to the EPS file with the dark background as well (for dark mode). Doesn't explain the gray background, of course. |
Might also be related to the ghostscript version. I saw a similar issue here: ImageMagick/ImageMagick#4797 |
The difference between --- _form0_dark_tmp.eps
+++ _form0_dark_tmp_corr.eps
@@ -1,7 +1,7 @@
%!PS-Adobe-3.0 EPSF-3.0
%%Invocation: gs -q -dBATCH -dNOPAUSE -P- -dNOSAFER -sDEVICE=eps2write ? ? -f ?
-%%BoundingBox: 0 0 612 792
-%%HiResBoundingBox: 0.00 0.00 612.00 792.00
+%%BoundingBox: 234 573 379 643
+%%HiResBoundingBox: 234.036 573.03 378.864 642.744
%%Creator: GPL Ghostscript 10011 (eps2write)
%%LanguageLevel: 2
%%CreationDate: D:20230528140215+02'00' What ghostscript version are you running? |
@meator Checked on my Linux machine with gs 9.50: output is ok. Then tried on my Mac with ghostscript 10.01.1: I see the same issue as you reported |
Yay! It's reproducible! Now is it a doxygen issue or a ghostscript issue? By the way here's mine:
|
Looks like I can get it to work correctly by changing diff --git a/src/formula.cpp b/src/formula.cpp
index 65597ec384..0c73baa96a 100644
--- a/src/formula.cpp
+++ b/src/formula.cpp
@@ -468,7 +468,7 @@ static bool createPNG(const QCString &formBase,const QCString &outFile,double sc
{
const size_t argsLen = 4096;
char args[argsLen];
- qsnprintf(args,argsLen,"-q -dNOSAFER -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=pnggray -dGraphicsAlphaBits=4 -dTextAlphaBits=4 "
+ qsnprintf(args,argsLen,"-q -dNOSAFER -dBATCH -dNOPAUSE -dEPSCrop -sDEVICE=pngalpha -dGraphicsAlphaBits=4 -dTextAlphaBits=4 "
"-r%d -sOutputFile=%s %s_tmp_corr.eps",static_cast<int>(scaleFactor*72),qPrint(outFile),qPrint(formBase));
if (Portable::system(Portable::ghostScriptCommand(),args)!=0)
{ can you test if this also fixed the problem for you? |
A bit after the party now, but for completeness,.
|
|
A bit of a hack, but things seem to start looking better if we slightly increase the bounding box: diff --git a/src/formula.cpp b/src/formula.cpp
index 0c73baa96a..f4f438d058 100644
--- a/src/formula.cpp
+++ b/src/formula.cpp
@@ -441,11 +441,11 @@ static bool updateEPSBoundingBox(const QCString &formBase,
{
if (line.rfind("%%BoundingBox",0)==0)
{
- epsOut << "%%BoundingBox: " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
+ epsOut << "%%BoundingBox: " << std::max(0,x1-1) << " " << std::max(0,y1-1) << " " << (x2+1) << " " << (y2+1) << "\n";
}
else if (line.rfind("%%HiResBoundingBox",0)==0)
{
- epsOut << "%%HiResBoundingBox: " << x1hi << " " << y1hi << " " << x2hi << " " << y2hi << "\n";
+ epsOut << "%%HiResBoundingBox: " << std::max(0.0,x1hi-1.0) << " " << std::max(0.0,y1hi-1.0) << " " << (x2hi+1.0) << " " << (y2hi+1.0) << "\n";
}
else
{ can you try this? |
It looks like it's working now. Thanks @doxygen ! |
I just tested the both changes together for the original example:
@meator can you also publish the examples the examples with the matrices, so I can test them as well? |
/**
* @f[
* A=
* \begin{bmatrix}
* 7 & 0 & 6 & 0 & 0 & 0 \\
* 0 & 3 & 0 & 4 & 3 & 0 \\
* 0 & 0 & 8 & 0 & 1 & 7 \\
* 0 & 0 & 0 & 0 & 0 & 0 \\
* 9 & 0 & 0 & 0 & 5 & 0 \\
* 0 & 4 & 0 & 0 & 0 & 9 \\
* \end{bmatrix}
* @f]
*
* @f{align*}{
* \mathit{VAL} &= [7, 6, 3, 4, 3, 8, 1, 7, 9, 5, 4, 9] \\
* \mathit{IR} &= [1, 1, 2, 2, 2, 3, 3, 3, 5, 5, 6, 6] \\
* \mathit{IC} &= [1, 3, 2, 4, 5, 3, 5, 6, 1, 5, 2, 6] \\
* @f}
* @f[
* A=
* \begin{bmatrix}
* 7 & 0 & 6 & 0 & 0 & 0 \\
* 0 & 3 & 0 & 4 & 3 & 0 \\
* 0 & 0 & 8 & 0 & 1 & 7 \\
* 0 & 0 & 0 & 0 & 0 & 0 \\
* 9 & 0 & 0 & 0 & 5 & 0 \\
* 0 & 4 & 0 & 0 & 0 & 9 \\
* \end{bmatrix}
* \Rightarrow
* \begin{bmatrix}
* 7 & 0 & 6 & 0 & 0 & 0 \\
* 0 & 3 & 0 & 4 & 3 & 0 \\
* 0 & 0 & 8 & 0 & 1 & 7 \\
* - & - & - & - & - & - \\
* 0 & 0 & 0 & 0 & 0 & 0 \\
* 9 & 0 & 0 & 0 & 5 & 0 \\
* 0 & 4 & 0 & 0 & 0 & 9 \\
* \end{bmatrix}
* @f]
*
* @f{align*}{
* \mathit{VAL} &= [7, 3, 6, 8, 4, 3, 1, 7 | 9, 4, 5, 9] \\
* \mathit{IR} &= [1, 2, 1, 3, 2, 2, 3, 3 | 5, 6, 5, 6] \\
* \mathit{IC} &= [1, 2, 3, 3, 4, 5, 5, 6 | 1, 2, 5, 6] \\
* \mathit{index} &= [1, 9] \\
* @f}
*/ This requires |
@meator Thanks for the example. Just tested it and looks all OK. |
In the issue doxygen#10096 there was a problem with the bounding box of the formulas, to inspect the temporary files it would need a rebuild with the remove flag unset. With the -option `-d formula` it is now possible to get the these files (
@albert-github Thanks for making temporary files keepable at runtime!
By the way is this a bug in the new ghostscript or did doxygen do something wrong? |
@meator I'd say it is a bug in ghostscript that I now worked around. |
This issue was previously marked 'fixed but not released', |
Describe the bug
I am trying to render simple equations via doxygen's builtin LaTeX capabilities. But they seem to be (slightly) broken.
Here is my MRE:
I have named this file
test.dox
to make doxygen find it. It also requiresEXTRA_PACKAGES = {amsmath}
in theDoxyfile for the
align*
environment.The rendered equation has a weird gray background (it should be black) and the last line
(beginning with
IC
) doesn't have square brackets around1, 3, 2, 4, 5, 3, 5, 6, 1, 5, 2, 6
.This is what doxygen produces for the dark version of the equation: _formulas_dark.txt (This file is actually
.tex
but GitHub doesn't allow me to upload files with that extension).When I run
pdflatex
on this, I get the expected output: _formulas_dark.pdf. But doxygen's output is broken.Screenshots
Here is the (broken) equation (generated by Dockerfile below):
This is the same example but with
FORMULA_FONTSIZE = 20
to make it more visible:It looks like there are some traces of the missing square brackets in the screenshots if you look carefully.
To Reproduce
Here is the entire directory: latex.tar.gz.
I have created a Dockerfile that can reproduce the problem:
Version
The Dockerfile uses version
1.9.7 (a2f34e1ed90f83713dc347b5134920f32c455d46)
, but I have tested this on1.9.7
and
1.9.5
(both compiled through my package manager). I am running Void Linux.Additional context
It was working flawlessly for me before but suddenly it broke. I have created the Dockerfile to try to verify that I didn't
break anything on my system but the clean Dockerfile is also broken. Could this be caused by a missing dependency?
I get no warnings nor errors when running
doxygen
.Void is rolling release, so an update could have broken it. I know for sure that this wasn't caused by an update of doxygen
itself, it could have been one of the tools that are used by doxygen to convert LaTeX into image. If I knew exactly how
doxygen converts LaTeX into image, I could maybe debug this further. How does it do it?
The text was updated successfully, but these errors were encountered: