# Latex Transparent Preview

**URL:** <https://org-roam.discourse.group/t/latex-transparent-preview/887>\
**Category:** Troubleshooting\
**Created:** [October 21, 2020, 1:51am UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887 "2020-10-21T01:51:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![noe](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@noe](https://org-roam.discourse.group/u/noe)\
**Post date:** [October 21, 2020, 1:51am UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/1 "2020-10-21T01:51:08Z")

</div>

I believe most of people who use org-roam as their go to knowledge management tool would have particular setting regarding latex setup.  
I am trying to achieve a transparent latex preview in org buffers.  
I hate the fact latex code renders like this

 ![noob](https://global.discourse-cdn.com/free1/uploads/orgroam/original/1X/5f66a679d9728d3d1f896a302a3dd663c9413fa7.png)

I would like to configure it like this. I did find a way to set the background of org-latex-format option to my background color scheme but whenever I restarted it is overwritten by the theme default color.  
I am complete noob when it comes to emacs or elisp, would like if some one could help with it or share their latex configuration for org-roam.  
Thanks

I am using doom emacs with spacemacs light theme.  
with these lines added to my config.el

(custom-set-variables  
;; custom-set-variables was added by Custom.  
;; If you edit it by hand, you could mess it up, so be careful.  
;; Your init file should contain only one such instance.  
;; If there is more than one, they won’t work right.  
'(org-format-latex-options  
(quote  
(:foreground default :background “#efeae9” :scale 1.5 :html-foreground “Black” :html-background “Transparent” :html-scale 1.0 :matchers  
(“begin” “1" "” “$$” “\(” “\[”))))

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 8:17am UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/2 "2020-10-21T08:17:35Z")

</div>

@noe,  
I no longer use Doom. I’ll let Doom users to step in.

Don’t use `customize` with Doom. I think Doom “tucks” your customizing away in a special file for you (I believe it’s `~/.emacs.d/.local/custom.el` by default), and I believe it disables it for you automatically.

This is by design, and is because Doom wants you to use `:custom` option in its own variation of `use-package`, `use-package!` (note the “!” at the end).

So… Two options.

Put `setq` somewhere after your `org` setting in your `config.el`.

```auto
(setq org-format-latex-options
  (quote (:foreground default :background “#efeae9” :scale 1.5 :html-foreground “Black” :html-background “Transparent” :html-scale 1.0 :matchers
             (“begin” “1" "” “$$” “\(” “\[”))))

```

Alternatively, something like this:

```auto
(use-package! org
              :custom
               (setq org-format-latex-options
                 (quote
                  (:foreground default
                   :background “#efeae9”
                   :scale 1.5 :html-foreground “Black”
                   :html-background “Transparent”
                   :html-scale 1.0
                   :matchers (“begin” “1" "” “$$” “\(” “\[”)))))

```

I think `org-format-latex-options` can be in your `:config` part, instead of `:custom`.

Hopefully one of these works for you.

---

<div class="post-metadata">

**Author:** ![noe](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@noe](https://org-roam.discourse.group/u/noe)\
**Post date:** [October 21, 2020, 3:29pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/3 "2020-10-21T15:29:21Z")

</div>

Thank you @nobiot for writing, I have tried both option but background property does not change when I look up in emacs using customize group.  
I have also tried

> (after! org-latex  
> (setq org-format-latex-options  
> (quote  
> (:foreground default :background auto :scale 1.5 :html-foreground “Black” :html-scale 1.0 :matchers  
> (“begin” “$1” “$” “$$” “\(” “\[”)))))  
> but it doesn’t.

The org-latex-format-option transparent is always set to spacemacs light theme default face color.  
I have cleared the cache of latex images as well.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 4:01pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/4 "2020-10-21T16:01:22Z")

</div>

> [@noe](#):
>
> The org-latex-format-option transparent is always set to spacemacs light theme default face color.

I misunderstood that this is what you would like to do from the code snippet, but that’s not what you are going for…Then, I am afraid I don’t understand what you wish to achieve.

In the part quoted below, you seem to want to overwrite something when something happens. Sorry not clear to me. I’ll let someone else to jump in and help you. I don’t use org-latex; that’s probably why I don’t understand your wish.

> a way to set the background of org-latex-format option to my background color scheme but whenever I restarted it is overwritten by the theme default color.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 4:12pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/5 "2020-10-21T16:12:18Z")

</div>

> [@noe](#):
>
> background property does not change when I look up in emacs using customize group.

By the way, this is probably correct behaviour. You are using Doom. I don’t believe you are encouraged to use customize group. setq does not affect what you see in customize group (it might say something like “value changed ouside customising”); it’s a different way to set variables.

---

<div class="post-metadata">

**Author:** ![noe](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@noe](https://org-roam.discourse.group/u/noe)\
**Post date:** [October 21, 2020, 4:25pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/6 "2020-10-21T16:25:35Z")

</div>

![noob2](https://global.discourse-cdn.com/free1/uploads/orgroam/original/1X/9b3ce7be52a27f0eaba2ec3a08844cc01caf3b03.png)

I would like to have something like this. This I achieved using customize group and setting org-latex-format to theme background. so the image generated from latex matches with my theme color. I can’t get this change to be reflected permanently in emacs. Even if I set the variable in config, it somehow resets to theme default color.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 4:32pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/7 "2020-10-21T16:32:32Z")

</div>

:custom keyword within use-package! should do what customize group does. if this does not happen, try :init keyword. I think it is Doom that removes your changes you did in customize group.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 4:37pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/8 "2020-10-21T16:37:36Z")

</div>

> [@noe](#):
>
> (after! org-latex  
> (setq org-format-latex-options

Also, if this didn’t do what you wanted, I surmise that org-format-latex-options need to be set before org-latex, not after. Did you try removing this after! part?

---

<div class="post-metadata">

**Author:** ![noe](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@noe](https://org-roam.discourse.group/u/noe)\
**Post date:** [October 21, 2020, 4:41pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/9 "2020-10-21T16:41:40Z")

</div>

Yes i tried it but it didn’t work. I also tried to run the code after the theme is loaded via hook but that also didn’t work. I’ll further explore how doom emacs load things. Thank you for your help. I’ll update if i got this working.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 4:50pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/10 "2020-10-21T16:50:13Z")

</div>

> [@noe](#):
>
> I have tried both option but background property does not change when I look up in emacs using customize group.

And you say you checked that the first two options didn’t work by looking at customizing group. I assume you also saw the actual note and latex to come to that conclusion (?).

Tricky, this issue…

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 21, 2020, 5:19pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/11 "2020-10-21T17:19:46Z")

</div>

> [@nobiot](#):
>
> ```auto
> (use-package! org
> :custom
> (setq org-format-latex-options
> (quote
> (:foreground default
> :background “#efeae9”
> :scale 1.5 :html-foreground “Black”
> :html-background “Transparent”
> :html-scale 1.0
> :matchers (“begin” “1" "” “$” “\(” “\[”)))))
> 
> ```

@noe

I think I was incorretly using `:custom` option.

`use-package` [documentation](https://github.com/jwiegley/use-package#customizing-variables) has this below

```auto
(use-package comint
  :custom
  (comint-buffer-maximum-size 20000 "Increase comint buffer size.")
  (comint-prompt-read-only t "Make the prompt read only."))

```

So… the code snippet above, probably, should have been without `setq` (`setq` can change the loading order, I think):

```auto
(use-package! org
              :custom
               (org-format-latex-options
                 (quote
                  (:foreground default
                   :background “#efeae9”
                   :scale 1.5 :html-foreground “Black”
                   :html-background “Transparent”
                   :html-scale 1.0
                   :matchers (“begin” “1" "” “$” “\(” “\[”)))))

```

---

<div class="post-metadata">

**Author:** ![albigujn](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@albigujn](https://org-roam.discourse.group/u/albigujn)\
**Post date:** [October 24, 2020, 7:24am UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/12 "2020-10-24T07:24:37Z")

</div>

One thing I struggled with was setting it up so that the background is truly _transparent_ - not just that the Latex image has background color matching the theme’s background. This makes a difference when you have different types of background colors. For example,

1. Some nice themes like Leuven highlight different header levels with different background colors to make them stand out
2. hl-line-mode slightly highlights the current line which is very useful to keep track of your location.

In these cases, the Latex inline image will still have a background color that doesn’t match the snippet’s actual background. I’m very interested to find a solution but it doesn’t appear to be possible as far as I can tell.

---

<div class="post-metadata">

**Author:** ![noe](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@noe](https://org-roam.discourse.group/u/noe)\
**Post date:** [October 24, 2020, 1:58pm UTC](https://org-roam.discourse.group/t/latex-transparent-preview/887/13 "2020-10-24T13:58:54Z")

</div>

Thanks for pitching in. You are right about it, just a temporary solution I found is changing the theme to “modus-operandi”.Without any changes latex renders renders nicely as background.  
example.

 ![modus-theme](https://global.discourse-cdn.com/free1/uploads/orgroam/original/1X/807bdb5ab22ef85de2c3b166be290faad38aadb8.png)

Currently, I use emacs primarly for note taking but I guess this wont blend nicely with other program eg. org-adenda .
