Re: Bug: Can't set background color of latex fragment

2021-05-19 Thread Roshan Shariff
Hi Sébastien,

I originally made my patch because otherwise adding '(:background
"Transparent") to org-format-latex-options always resulted in a white
background (\pagecolor{white} would be forcefully added to the
generated LaTeX). Then I found that dvipng still produced a white
background even without a \pagecolor{...} directive, so I added the
-bg Transparent option. This is unlike dvisvgm, which produces an
opaque background when \pagecolor{...} is present and a transparent
background otherwise.

I didn't realize that dvipng -bg Transparent would completely ignore
the \pagecolor{...} command even if it was present. Perhaps the best
solution that allows the background color to be customized with dvipng
is to remove "-bg Transparent" from the default dvipng command line.
For people who need transparency, perhaps another "dvipng
(transparent)" option can be created, or they can use dvisvgm. This is
useful for HTML export, for example.

That said, I haven't had any issues with Emacs rendering transparent
PNGs (version 27.2 on Linux and macOS). It uses the background color
of whichever face is applied to LaTeX fragments (which seems to be
org-block, along with font-latex-verbatim-face for inline formulae). I
personally find it convenient to customize these faces as needed.

Regards,
Roshan

On Wed, May 19, 2021 at 12:30 AM Sébastien Miquel
 wrote:
>
> Hi Roshan,
>
> Roshan Shariff writes:
>
> I can confirm this bug with dvipng --- with the "-bg Transparent"
> option, dvipng ignores the background color from the input tex file,
> whereas without that option it always produces an opaque background.
> There's currently no way to dynamically change command line
> parameters, so I'm not sure how to solve this problem while supporting
> both use cases.
>
>
> I asked about this behaviour on the dvipng mailing list, and the
> maintainer doesn't consider it a bug, see
> https://lists.nongnu.org/archive/html/dvipng/2021-05/msg2.html.
>
> Can you explain the use for a `Transparent` background ? Transparent
> images are poorly supported in emacs, all it does is render it with
> the background color of the default face -- which may not be the
> expected result.
>
> Regards,
>
> --
> Sébastien Miquel
>
>
> On Wed, Apr 7, 2021 at 1:38 PM Sébastien Miquel
>  wrote:
>
> To reproduce with `emacs -Q` :
>   - Open an org buffer
>   - Call ~(setq org-format-latex-options '(:foreground default
> :background "Black" :matchers ("$")))~
>   - Call =C-c C-x C-l= (org-latex-preview) on a latex fragment such as
> $abc$
>
> This bug was introduced by the commit 2f9e1569f which adds the option
> `-bg Transparent` to the arguments of `dvipng`. According to its
> manual, this option should be ignored if a background is already set,
> but it doesn't seem to be. Perhaps org should set it differently.
>
> --
> Sébastien Miquel
>
>
>



Re: Bug: Can't set background color of latex fragment

2021-05-18 Thread Sébastien Miquel

Hi Roshan,

Roshan Shariff writes:

I can confirm this bug with dvipng --- with the "-bg Transparent"
option, dvipng ignores the background color from the input tex file,
whereas without that option it always produces an opaque background.
There's currently no way to dynamically change command line
parameters, so I'm not sure how to solve this problem while supporting
both use cases.


I asked about this behaviour on the dvipng mailing list, and the
maintainer doesn't consider it a bug, see
https://lists.nongnu.org/archive/html/dvipng/2021-05/msg2.html.

Can you explain the use for a `Transparent` background ? Transparent
images are poorly supported in emacs, all it does is render it with
the background color of the default face -- which may not be the
expected result.

Regards,

--
Sébastien Miquel



On Wed, Apr 7, 2021 at 1:38 PM Sébastien Miquel
  wrote:

To reproduce with `emacs -Q` :
   - Open an org buffer
   - Call ~(setq org-format-latex-options '(:foreground default
 :background "Black" :matchers ("$")))~
   - Call =C-c C-x C-l= (org-latex-preview) on a latex fragment such as
 $abc$

This bug was introduced by the commit 2f9e1569f which adds the option
`-bg Transparent` to the arguments of `dvipng`. According to its
manual, this option should be ignored if a background is already set,
but it doesn't seem to be. Perhaps org should set it differently.

--
Sébastien Miquel





Re: Bug: Can't set background color of latex fragment

2021-04-10 Thread Roshan Shariff
I can confirm this bug with dvipng --- with the "-bg Transparent"
option, dvipng ignores the background color from the input tex file,
whereas without that option it always produces an opaque background.
There's currently no way to dynamically change command line
parameters, so I'm not sure how to solve this problem while supporting
both use cases.

On Wed, Apr 7, 2021 at 1:38 PM Sébastien Miquel
 wrote:
>
>
> To reproduce with `emacs -Q` :
>   - Open an org buffer
>   - Call ~(setq org-format-latex-options '(:foreground default
> :background "Black" :matchers ("$")))~
>   - Call =C-c C-x C-l= (org-latex-preview) on a latex fragment such as
> $abc$
>
> This bug was introduced by the commit 2f9e1569f which adds the option
> `-bg Transparent` to the arguments of `dvipng`. According to its
> manual, this option should be ignored if a background is already set,
> but it doesn't seem to be. Perhaps org should set it differently.
>
> --
> Sébastien Miquel



Bug: Can't set background color of latex fragment

2021-04-07 Thread Sébastien Miquel



To reproduce with `emacs -Q` :
 - Open an org buffer
 - Call ~(setq org-format-latex-options '(:foreground default
   :background "Black" :matchers ("$")))~
 - Call =C-c C-x C-l= (org-latex-preview) on a latex fragment such as
   $abc$

This bug was introduced by the commit 2f9e1569f which adds the option
`-bg Transparent` to the arguments of `dvipng`. According to its
manual, this option should be ignored if a background is already set,
but it doesn't seem to be. Perhaps org should set it differently.

--
Sébastien Miquel