TobiasZawada / texfrag

Emacs package for previewing LaTeX fragments such as in doxygen comments.
GNU General Public License v3.0
68 stars 4 forks source link

Dark background for tikz fragments #28

Closed mroman42 closed 4 months ago

mroman42 commented 2 years ago

Equations on a dark background take a white color, as they should (#19). However, tikz figures over a dark background are still drawn in black.

Is there a way to override this mechanism?

dozed commented 2 years ago

One option is to add a custom tikzset to the texfrag-header. The following changes the color of all nodes to white:

(eval-after-load "preview"
  '(add-to-list 'preview-default-preamble "\\PreviewEnvironment{tikzpicture}" t))

(defcustom custom-texfrag-header
  "
\\documentclass{article}
\\usepackage{amsmath,amsfonts}
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{tikz}
\\usetikzlibrary{positioning}
\\usetikzlibrary{fit}
\\tikzset{every node/.style={white}}
"
  "LaTeX header inserted by the function `texfrag-header-function' into the LaTeX buffer."
  :group 'texfrag
  :type 'string)

(add-hook 'markdown-mode-hook
  (lambda ()
    (setq texfrag-header-function (lambda () custom-texfrag-header))
  ))
TobiasZawada commented 4 months ago

@mroman42 Is @dozed solution feasible for you?

mroman42 commented 4 months ago

Yes, thank you, @dozed. I used a macro file loaded on each file for a while; at some point, I just started using a white background anyway.

\tikzset{color=localblack}
\tikzset{every picture/.style={color=localblack,draw}}

I will just close the issue (cc @TobiasZawada).