bg face for latex is now default background

This commit is contained in:
Thomas Dehaeze 2020-03-20 12:22:17 +01:00
parent 6764c1a683
commit 1c8bbf965c

View File

@ -208,9 +208,6 @@ Turn off auto-fill mode that add line breaks.
;; Avoid accidentally editing folded regions, say by adding text after an Org “⋯”.
(setq org-catch-invisible-edits 'show)
;; Highligh latex parts in org mode
(setq org-highlight-latex-and-related '(native))
;; The following setting hides blank lines between headings which keeps folded view nice and compact.
(setq org-cycle-separator-lines 0)
@ -231,96 +228,6 @@ TAB was changed to toggle only the visibility state of the current subtree, rath
(remove-hook 'org-tab-first-hook #'+org-cycle-only-current-subtree-h))
#+end_src
** Org latex fragment
Don't change the font size for subscripts and superscripts in latex fragments.
This cause the orgmode tables not to be well aligned.
#+begin_src emacs-lisp
(after! org
(setq font-latex-fontify-script nil))
#+end_src
#+begin_src emacs-lisp
(defvar tdh-org-latex-fragment-last nil
"Holds last fragment/environment you were on.")
(defun tdh-org-in-latex-fragment-p ()
"Return the point where the latex fragment begins, if inside
a latex fragment. Else return false"
(let* ((el (org-element-context))
(el-type (car el)))
(and (or (eq 'latex-fragment el-type) (eq 'latex-environment el-type))
(org-element-property :begin el))))
(defun tdh-org-latex-fragment-toggle ()
"Toggle a latex fragment image "
(and (eq 'org-mode major-mode)
(let ((begin (tdh-org-in-latex-fragment-p)))
(cond
;; were on a fragment and now on a new fragment
((and
;; fragment we were on
tdh-org-latex-fragment-last
;; and are on a fragment now
begin
;; but not on the last one this is a little tricky. as you edit the
;; fragment, it is not equal to the last one. We use the begin
;; property which is less likely to change for the comparison.
(not (and tdh-org-latex-fragment-last
(= begin
tdh-org-latex-fragment-last))))
;; go back to last one and put image back, provided there is still a fragment there
(save-excursion
(goto-char tdh-org-latex-fragment-last)
(when (tdh-org-in-latex-fragment-p) (org-preview-latex-fragment))
;; now remove current image
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov)))
;; and save new fragment
(setq tdh-org-latex-fragment-last begin)))
;; were on a fragment and now are not on a fragment
((and
;; not on a fragment now
(not begin)
;; but we were on one
tdh-org-latex-fragment-last)
;; put image back on, provided that there is still a fragment here.
(save-excursion
(goto-char tdh-org-latex-fragment-last)
(when (tdh-org-in-latex-fragment-p) (org-preview-latex-fragment)))
;; unset last fragment
(setq tdh-org-latex-fragment-last nil))
;; were not on a fragment, and now are
((and
;; we were not one one
(not tdh-org-latex-fragment-last)
;; but now we are
begin)
;; remove image
(save-excursion
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov))))
(setq tdh-org-latex-fragment-last begin))))))
#+end_src
** Org Inline Images
Display the real size of images and not the one set with =attr_latex: :width \linewidth= for instance.
#+begin_src emacs-lisp
@ -915,6 +822,158 @@ by spaces.
#+end_src
** Org LaTeX
*** Org latex fragment
Don't change the font size for subscripts and superscripts in latex fragments.
This cause the orgmode tables not to be well aligned.
#+begin_src emacs-lisp
(after! org
(setq font-latex-fontify-script nil))
#+end_src
#+begin_src emacs-lisp
(defvar tdh-org-latex-fragment-last nil
"Holds last fragment/environment you were on.")
(defun tdh-org-in-latex-fragment-p ()
"Return the point where the latex fragment begins, if inside
a latex fragment. Else return false"
(let* ((el (org-element-context))
(el-type (car el)))
(and (or (eq 'latex-fragment el-type) (eq 'latex-environment el-type))
(org-element-property :begin el))))
(defun tdh-org-latex-fragment-toggle ()
"Toggle a latex fragment image "
(and (eq 'org-mode major-mode)
(let ((begin (tdh-org-in-latex-fragment-p)))
(cond
;; were on a fragment and now on a new fragment
((and
;; fragment we were on
tdh-org-latex-fragment-last
;; and are on a fragment now
begin
;; but not on the last one this is a little tricky. as you edit the
;; fragment, it is not equal to the last one. We use the begin
;; property which is less likely to change for the comparison.
(not (and tdh-org-latex-fragment-last
(= begin
tdh-org-latex-fragment-last))))
;; go back to last one and put image back, provided there is still a fragment there
(save-excursion
(goto-char tdh-org-latex-fragment-last)
(when (tdh-org-in-latex-fragment-p) (org-preview-latex-fragment))
;; now remove current image
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov)))
;; and save new fragment
(setq tdh-org-latex-fragment-last begin)))
;; were on a fragment and now are not on a fragment
((and
;; not on a fragment now
(not begin)
;; but we were on one
tdh-org-latex-fragment-last)
;; put image back on, provided that there is still a fragment here.
(save-excursion
(goto-char tdh-org-latex-fragment-last)
(when (tdh-org-in-latex-fragment-p) (org-preview-latex-fragment)))
;; unset last fragment
(setq tdh-org-latex-fragment-last nil))
;; were not on a fragment, and now are
((and
;; we were not one one
(not tdh-org-latex-fragment-last)
;; but now we are
begin)
;; remove image
(save-excursion
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov))))
(setq tdh-org-latex-fragment-last begin))))))
#+end_src
#+begin_src emacs-lisp
(map! :map org-mode-map
;; Activate Automatic LaTeX fragment
:n ",ol" '(lambda () (interactive) (add-hook 'post-command-hook 'tdh-org-latex-fragment-toggle t))
;; ;; Disable Automatic LaTeX fragment
:n ",oL" '(lambda () (interactive) (remove-hook 'post-command-hook 'tdh-org-latex-fragment-toggle)))
#+end_src
*** TODO Latex Fragments
- [ ] The remove hook does not seems to work
http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode/
#+begin_src emacs-lisp
(after! org
;; Highligh latex parts in org mode
(setq org-highlight-latex-and-related '(native))
;; Use F9 to globally generate all the latex fragments
(map! :map org-mode-map :n "<f9>" (lambda () (interactive) (org-preview-latex-fragment 16)))
;; Put all the preview images in some directory
(setq org-preview-latex-image-directory "~/.ltximg/")
;; Define backends to preview LaTeX fragments
(setq org-preview-latex-process-alist '((imagemagick
:programs ("pdflatex" "convert")
:description "pdf > png"
:message "you need to install the programs: pdflatex and imagemagick."
:image-input-type "pdf"
:image-output-type "png"
:image-size-adjust (0.6 . 0.6)
:latex-compiler ("pdflatex -interaction nonstopmode -output-directory %o %f")
:image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
(dvipng
:programs ("latex" "dvipng")
:description "dvi > png"
:message "you need to install the programs: latex and dvipng."
:image-input-type "dvi"
:image-output-type "png"
:image-size-adjust (0.5 . 0.5)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvipng -D %D -T tight -o %O %f"))
(dvisvgm
:programs ("pdflatex" "dvisvgm")
:description "dvi > svg"
:message "you need to install the programs: latex and dvisvgm."
:image-input-type "dvi"
:image-output-type "svg"
:image-size-adjust (0.7 . 0.7)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvisvgm %f -n -b min -c %S -o %O"))
))
;; Use imagemagick/dvisvgm to generate png from pdf
(setq org-preview-latex-default-process 'dvipng)
;; Colors of latex fragments
(setq org-format-latex-options (plist-put org-format-latex-options :foreground 'default))
(setq org-format-latex-options (plist-put org-format-latex-options :background (face-background 'fringe)))
)
#+end_src
*** LaTeX Classes
#+begin_src emacs-lisp
(after! org
@ -1046,59 +1105,6 @@ Special Environments
)
#+end_src
*** TODO Latex Fragments
- [ ] The remove hook does not seems to work
http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode/
#+begin_src emacs-lisp
(after! org
(map! :map org-mode-map
;; Activate Automatic LaTeX fragment
:n ",ol" '(lambda () (interactive) (add-hook 'post-command-hook 'tdh-org-latex-fragment-toggle t))
;; ;; Disable Automatic LaTeX fragment
:n ",oL" '(lambda () (interactive) (remove-hook 'post-command-hook 'tdh-org-latex-fragment-toggle)))
;; Use F9 to globally generate all the latex fragments
(map! :map org-mode-map :n "<f9>" (lambda () (interactive) (org-preview-latex-fragment 16)))
;; Put all the preview images in some directory
(setq org-preview-latex-image-directory "~/.ltximg/")
;; Define backends to preview LaTeX fragments
(setq org-preview-latex-process-alist '((imagemagick
:programs ("pdflatex" "convert")
:description "pdf > png"
:message "you need to install the programs: pdflatex and imagemagick."
:image-input-type "pdf"
:image-output-type "png"
:image-size-adjust (0.6 . 0.6)
:latex-compiler ("pdflatex -interaction nonstopmode -output-directory %o %f")
:image-converter ("convert -density %D -trim -antialias %f -quality 100 %O"))
(dvipng
:programs ("latex" "dvipng")
:description "dvi > png"
:message "you need to install the programs: latex and dvipng."
:image-input-type "dvi"
:image-output-type "png"
:image-size-adjust (0.5 . 0.5)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvipng -D %D -T tight -o %O %f"))
(dvisvgm
:programs ("pdflatex" "dvisvgm")
:description "dvi > svg"
:message "you need to install the programs: latex and dvisvgm."
:image-input-type "dvi"
:image-output-type "svg"
:image-size-adjust (0.7 . 0.7)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvisvgm %f -n -b min -c %S -o %O"))
))
;; Use imagemagick/dvisvgm to generate png from pdf
(setq org-preview-latex-default-process 'dvipng)
)
#+end_src
*** TODO Custom Export - Add Page and Label for LaTeX export
https://emacs.stackexchange.com/questions/156/emacs-function-to-convert-an-arbitrary-org-property-into-an-arbitrary-string-na?rq=1
@ -1454,7 +1460,7 @@ Nice Functions:
(map!
:map org-mode-map
(:desc "Insert Link"
:n "C-c i" #'org-ref-insert-ref-link))
:ni "C-c i" #'org-ref-insert-ref-link))
)
#+end_src
@ -2005,14 +2011,6 @@ https://emacs.stackexchange.com/questions/22430/rebind-org-babel-execute-src-blo
)
#+end_src
** TODO Theme
#+begin_src emacs-lisp
;; (after! org
;; (require 'color)
;; (set-face-attribute 'org-block nil :background (color-darken-name (face-attribute 'default :background) 3))
;; )
#+end_src
** Indentation
#+begin_src emacs-lisp
(after! org
@ -2208,6 +2206,14 @@ Actually this tangle the file and then go to the file. Maybe I would like to ign
(add-hook 'TeX-mode-hook #'TeX-fold-mode)
#+end_src
** Face Attributes
#+begin_src emacs-lisp :tangle no
(after! tex
(set-face-attribute 'font-latex-math-face nil :foreground (face-foreground 'default))
(set-face-attribute 'font-latex-math-face nil :background (face-background 'fringe))
)
#+end_src
** Master file
#+begin_src emacs-lisp
(setq-default TeX-master nil)