Make engrave handle this org file and apply some cosmetics
This commit is contained in:
parent
083ff19f16
commit
27401f8c4b
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@
|
||||
*.log
|
||||
*.lol
|
||||
*.lot
|
||||
*.lst
|
||||
*.out
|
||||
*.pdf
|
||||
*.run.xml
|
||||
|
156
README.org
156
README.org
@ -901,20 +901,22 @@ variable in section are compatible. The local variable ~compile-command~ in the
|
||||
=pdf= files) shows how to use the =latexmkrc= file.
|
||||
|
||||
#+attr_latex: :options breaklines
|
||||
#+caption[Tangle the Latexmk resource file]:
|
||||
#+caption: Tangle the Latexmk resource file.
|
||||
#+caption[Tangle the =Latexmk= resource file]:
|
||||
#+caption: Tangle the =Latexmk= resource file.
|
||||
#+name: lst:latexmkrc
|
||||
#+begin_src perl :tangle latexmkrc :comments none
|
||||
# pdf creator
|
||||
$pdf_mode = 4; # 4 means lualatex
|
||||
# pdf previewer and update pdf previewer
|
||||
$pdf_previewer = "emacsclient -e '(find-file-other-window %S)'";
|
||||
$pdf_update_method = 4; # 4 runs a command to force the update
|
||||
$pdf_update_method = 4; # 4 runs $pdf_update_command to force the update
|
||||
$pdf_update_command = "emacsclient -e '(with-current-buffer (find-buffer-visiting %S) (pdf-view-revert-buffer nil t))'";
|
||||
# see for instance glossary.latexmkrc
|
||||
add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
|
||||
add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
|
||||
$clean_ext .= " acr acn alg bbl dvi glo gls glg ist lol nav run.xml snm synctex.gz";
|
||||
# use ".=" to append to $clean_ext
|
||||
$clean_ext .= " acr acn alg bbl dvi glo gls glg ist lol lst";
|
||||
$clean_ext .= " nav run.xml snm synctex.gz";
|
||||
sub makeglossaries {
|
||||
my ($name, $path) = fileparse( $$Psource );
|
||||
return system "makeglossaries -d '$path' '$name'";
|
||||
@ -1940,7 +1942,8 @@ backward compatibility. See table [[tab:org-latex-class-tag-placeholder]] and ty
|
||||
(custom-set-variables
|
||||
'(org-latex-pdf-process
|
||||
;; https://tecosaur.github.io/emacs-config/#compiling
|
||||
("latexmk -f -pdf -%latex -interaction=nonstopmode -shell-escape -outdir=%o %f"))
|
||||
`(,(concat "latexmk -f -pdf -%latex"
|
||||
" -interaction=nonstopmode -shell-escape -outdir=%o %f")))
|
||||
'(org-latex-compiler "lualatex")
|
||||
'(org-latex-hyperref-template "\\hypersetup{
|
||||
pdfauthor={%a},
|
||||
@ -2124,24 +2127,32 @@ valid directories and files. In an [[https://orgmode.org/][Org-mode]] buffer th
|
||||
|
||||
This package aims to produce a versatile generic core which can process a
|
||||
fontified buffer and pass the data to any number of backends to deal with
|
||||
specific output formats and it should work with =org-mode=. *However*,
|
||||
[[https://github.com/tecosaur/engrave-faces#readme][Engrave Faces]] and [[info:org#Source blocks in LaTeX export][Org source block export to LaTeX (info)]] *are sofar incapable
|
||||
of handling this [[file:README.org]] file.*
|
||||
|
||||
Listing [[lst:ensure-and-fix-engrave-faces-installation]] ensures installation of
|
||||
=engrave-faces= and fixes =engrave-faces-latex= for multi-line documentation
|
||||
strings. Listing [[lst:ox-latex-engraved-filter-emacs-lisp-setup]] and
|
||||
[[lst:smart-latex-engrave-org-source-blocks]] allow to engrave =org-mode= source
|
||||
blocks to "floating unbreakable" or "non-floating breakable" LaTeX environments.
|
||||
specific output formats and it should work with =org-mode=. *Thanks to the
|
||||
listings below*, [[https://github.com/tecosaur/engrave-faces#readme][Engrave Faces]] and [[info:org#Source blocks in LaTeX export][Org source block export to LaTeX (info)]] *are
|
||||
capable of handling this [[file:README.org]] file:*
|
||||
1. Listing [[lst:ensure-engrave-faces-with-latex-face-mapper-fix]] ensures
|
||||
installation of =engrave-faces= and makes =engrave-faces-latex-face-mapper=
|
||||
handle multi-line documentation strings.
|
||||
2. Listing [[lst:ensure-engrave-faces-with-latex-face-apply-fix]] ensures
|
||||
installation of =engrave-faces= and makes =engrave-faces-latex-face-apply=
|
||||
handle symbolic color name strings (in addition to the hexadecimal strings).
|
||||
3. The =org-latex-engraved-source-block-filter= in listing
|
||||
[[lst:ox-latex-engraved-filter-emacs-lisp-setup]] and the
|
||||
=org-latex-engraved-preamble= customization in listing
|
||||
[[lst:smart-latex-engrave-org-source-blocks]] allow to engrave =org-mode= source
|
||||
blocks to "floating unbreakable" or "non-floating breakable" LaTeX
|
||||
environments.
|
||||
Listing [[lst:ox-latex-engraved-emacs-lisp-setup]] is shows how to use this
|
||||
configuration.
|
||||
|
||||
#+caption[Ensure =engrave-faces= installation and fix multiline docstrings]:
|
||||
#+caption: Ensure =engrave-faces= installation and fix multiline docstrings.
|
||||
#+name: lst:ensure-and-fix-engrave-faces-installation
|
||||
#+name: lst:ensure-engrave-faces-with-latex-face-mapper-fix
|
||||
#+begin_src emacs-lisp
|
||||
(when (ensure-package-installation 'engrave-faces)
|
||||
(require 'engrave-faces-latex nil t)
|
||||
(defun engrave-faces-latex-face-mapper-override (faces content)
|
||||
"Create a LaTeX representation of CONTENT With FACES applied."
|
||||
(autoload 'engrave-faces-latex-mathescape "engrave-faces-latex" nil t)
|
||||
(let* ((style (engrave-faces-preset-style faces))
|
||||
(protected-content
|
||||
(funcall
|
||||
@ -2179,6 +2190,46 @@ blocks to "floating unbreakable" or "non-floating breakable" LaTeX environments.
|
||||
(toggle-engrave-faces-latex-face-mapper-override))
|
||||
#+end_src
|
||||
|
||||
#+caption[Ensure =engrave-faces= installation and fix symbolic colors]:
|
||||
#+caption: Ensure =engrave-faces= installation and fix symbolic colors.
|
||||
#+name: lst:ensure-engrave-faces-with-latex-face-apply-fix
|
||||
#+begin_src emacs-lisp
|
||||
(when (ensure-package-installation 'engrave-faces)
|
||||
(require 'engrave-faces-latex nil t)
|
||||
(defun engrave-faces-latex--html-color (color)
|
||||
"Convert COLOR loosely to a string of six hexadecimal digits."
|
||||
(if (char-equal ?# (aref color 0))
|
||||
(substring color 1 7)
|
||||
(apply 'format "%02x%02x%02x"
|
||||
(mapcar (lambda (c) (ash c -8))
|
||||
(color-values color)))))
|
||||
|
||||
(defun engrave-faces-latex-face-apply-override (faces content)
|
||||
"Convert each compatible parameter of FACES to a LaTeX command applied to CONTENT."
|
||||
(let ((attrs (engrave-faces-merge-attributes faces)))
|
||||
(let ((bg (plist-get attrs :background))
|
||||
(fg (plist-get attrs :foreground))
|
||||
(it (eql (plist-get attrs :slant) 'italic))
|
||||
(bl (member (plist-get attrs :weight) '(bold extra-bold)))
|
||||
(st (plist-get attrs :strike-through)))
|
||||
(concat
|
||||
(when bg (concat "\\colorbox[HTML]{"
|
||||
(engrave-faces-latex--html-color bg) "}{"))
|
||||
(when fg (concat "\\textcolor[HTML]{"
|
||||
(engrave-faces-latex--html-color fg) "}{"))
|
||||
(when st "\\sout{") (when bl "\\textbf{") (when it "\\textit{")
|
||||
content
|
||||
(when bg "}") (when fg "}") (when st "}") (when bl "}") (when it "}")))))
|
||||
|
||||
(defun toggle-engrave-faces-latex-face-apply-override ()
|
||||
"Toggle `engrave-faces-latex-face-apply' advice."
|
||||
(interactive)
|
||||
(toggle-advice 'engrave-faces-latex-face-apply
|
||||
:override #'engrave-faces-latex-face-apply-override))
|
||||
|
||||
(toggle-engrave-faces-latex-face-apply-override))
|
||||
#+end_src
|
||||
|
||||
#+caption[Engrave to floating unbreakable or non-floating breakable environments]:
|
||||
#+caption: Define an =org-export= filter function to engrave =org-src-mode=
|
||||
#+caption: blocks to floating unbreakable LaTeX environments or non-floating
|
||||
@ -2225,41 +2276,51 @@ blocks to "floating unbreakable" or "non-floating breakable" LaTeX environments.
|
||||
[FVEXTRA-SETUP]
|
||||
|
||||
% Make code and line numbers normalsize. Make line numbers grey.
|
||||
\\renewcommand\\theFancyVerbLine{\\normalsize\\color{black!40!white}\\arabic{FancyVerbLine}}
|
||||
\\renewcommand\\theFancyVerbLine{
|
||||
\\normalsize\\color{black!40!white}\\arabic{FancyVerbLine}}
|
||||
% In case engrave-faces-latex-gen-preamble has not been run.
|
||||
\\providecolor{EfD}{HTML}{f7f7f7}
|
||||
\\providecolor{EFD}{HTML}{28292e}
|
||||
% To use \\DeclareTColorBox from the tcolorbox package:
|
||||
\\usepackage[breakable,xparse]{tcolorbox}
|
||||
% Define a Breakable environment to wrap the fontified code outside floats.
|
||||
\\DeclareTColorBox[]{Breakable}{o}%
|
||||
{
|
||||
colback=EfD,
|
||||
colframe=EFD,
|
||||
% Define a Breakable environment to fontify code outside floats.
|
||||
\\DeclareTColorBox[]{Breakable}{o}{
|
||||
colback=EfD, colframe=EFD, colupper=EFD,
|
||||
fontupper=\\normalsize\\setlength{\\fboxsep}{0pt},
|
||||
colupper=EFD,
|
||||
IfNoValueTF={#1}%
|
||||
{boxsep=1pt, arc=2.5pt, outer arc=1pt, boxrule=0.5pt, left=2pt}%
|
||||
{boxsep=2.5pt, arc=0pt, outer arc=0pt, boxrule=0pt, leftrule=1.5pt, left=0.5pt},
|
||||
right=2pt, top=1pt, bottom=1pt,
|
||||
breakable
|
||||
IfNoValueTF={#1}{
|
||||
boxsep=1pt, arc=1pt, outer arc=1pt, boxrule=0.5pt,
|
||||
}{
|
||||
boxsep=1pt, arc=0pt, outer arc=0pt, boxrule=0pt, leftrule=1pt
|
||||
},
|
||||
left=2pt, right=2pt, top=1pt, bottom=1pt, breakable
|
||||
}
|
||||
% Define an unbreakable Code environment to wrap the fontified code inside floats.
|
||||
\\DeclareTColorBox[]{Code}{o}%
|
||||
{
|
||||
colback=EfD,
|
||||
colframe=EFD,
|
||||
% Define an unbreakable Code environment to fontify code inside floats.
|
||||
\\DeclareTColorBox[]{Code}{o}{
|
||||
colback=EfD, colframe=EFD, colupper=EFD,
|
||||
fontupper=\\normalsize\\setlength{\\fboxsep}{0pt},
|
||||
colupper=EFD,
|
||||
IfNoValueTF={#1}%
|
||||
{boxsep=1pt, arc=1pt, outer arc=1pt, boxrule=0.5pt, left=2pt}%
|
||||
{boxsep=2.5pt, arc=0pt, outer arc=0pt, boxrule=0pt, leftrule=1.5pt, left=0.5pt},
|
||||
right=2pt, top=1pt, bottom=1pt,
|
||||
IfNoValueTF={#1}{
|
||||
boxsep=1pt, arc=1pt, outer arc=1pt, boxrule=0.5pt
|
||||
}{
|
||||
boxsep=1pt, arc=0pt, outer arc=0pt, boxrule=0pt, leftrule=1pt
|
||||
},
|
||||
left=2pt, right=2pt, top=1pt, bottom=1pt,
|
||||
}
|
||||
|
||||
[LISTINGS-SETUP]"))
|
||||
#+end_src
|
||||
|
||||
#+caption[Emacs setup to use =engrave-faces-latex= in =org-mode= smartly]:
|
||||
#+caption: Emacs setup to use =engrave-faces-latex= in =org-mode= smartly.
|
||||
#+name: lst:ox-latex-engraved-emacs-lisp-setup
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(with-eval-after-load 'ox-latex
|
||||
(make-variable-buffer-local 'org-export-filter-src-block-functions)
|
||||
(add-to-list 'org-export-filter-src-block-functions
|
||||
'org-latex-engraved-source-block-filter)
|
||||
(when (fboundp 'smart-latex-engrave-org-source-blocks)
|
||||
(smart-latex-engrave-org-source-blocks)))
|
||||
#+end_src
|
||||
|
||||
*** [[info:org#Adding Hyperlink Types][Making Org hyperlink types (info)]]
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: sec:making-org-hyperlink-types
|
||||
@ -2400,10 +2461,12 @@ variables in order to export the =info-org-link= types in this document to
|
||||
(setq org-info-emacs-documents (delete "org" org-info-emacs-documents))
|
||||
(make-variable-buffer-local 'org-info-other-documents)
|
||||
(setq org-info-other-documents
|
||||
(cl-union '(("consult" . "https://github.com/minad/consult")
|
||||
(cl-union
|
||||
'(("consult" . "https://github.com/minad/consult")
|
||||
("embark" . "https://github.com/oantolin/embark")
|
||||
("marginalia" . "https://github.com/minad/marginalia")
|
||||
("maxima" . "https://maxima.sourceforge.io/docs/manual/maxima_singlepage.html")
|
||||
("maxima" .
|
||||
"https://maxima.sourceforge.io/docs/manual/maxima_singlepage.html")
|
||||
("org" . "https://orgmode.org/org.html")
|
||||
("orderless" . "https://github.com/oantolin/orderless")
|
||||
("sly" . "https://joaotavora.github.io/sly/")
|
||||
@ -2755,8 +2818,8 @@ Listing [[lst:use-latex-header-1]], [[lst:use-latex-header-2]], [[lst:use-latex-
|
||||
headheight=20mm,
|
||||
top=40mm,
|
||||
bottom=20mm,
|
||||
left=60pt,
|
||||
right=60pt,
|
||||
left=0.1\paperwidth,
|
||||
right=0.1\paperwidth,
|
||||
heightrounded,
|
||||
verbose,
|
||||
]{geometry}
|
||||
@ -2881,8 +2944,8 @@ exporting from Org-mode to LaTeX.
|
||||
(make-variable-buffer-local 'org-latex-toc-command)
|
||||
(setq org-latex-toc-command "
|
||||
\\tableofcontents\\label{toc}
|
||||
\\listoflistings
|
||||
\\listoftables
|
||||
\\listoffigures
|
||||
\\newpage
|
||||
")
|
||||
|
||||
@ -3936,7 +3999,7 @@ Structural editing keeps character pairs (for instance parentheses, curly and
|
||||
square brackets as well as single and double quotes) balanced to leave code (for
|
||||
instance Lisp and Python) and text (for instance LaTeX and Org) structure
|
||||
intact. I use [[https://github.com/Fuco1/smartparens][smartparens]] which offers a normal mode (=smartparens-mode=) and a
|
||||
a strict mode (=smartparens-strict-mode=). Although both modes insert character
|
||||
strict mode (=smartparens-strict-mode=). Although both modes insert character
|
||||
pairs, the normal mode allows to delete one of the paired characters easily
|
||||
while the strict mode does not. Therefore, the strict mode is more for code
|
||||
editing since it never breaks programming language rules and the normal mode is
|
||||
@ -4150,7 +4213,7 @@ point movements visually.
|
||||
;; to prevent the warning triggered by lazy loading.
|
||||
(when (require 'pulse nil 'noerror)
|
||||
;; https://karthinks.com/software/batteries-included-with-emacs/
|
||||
;; https://www.reddit.com/r/emacs/comments/jwhr6g/batteries_included_with_emacs/
|
||||
;; https://github.com/karthink/.emacs.d/blob/master/init.el#L2077
|
||||
(defun flash-line-around-point (&rest _)
|
||||
"Flash the line around point."
|
||||
(let ((pulse-iterations 16)
|
||||
@ -4447,7 +4510,8 @@ enable =emms=.
|
||||
'(("http://www.howardism.org/index.xml" h-abrams)
|
||||
("https://emacshorrors.com/feed.atom" v-schneidermann)
|
||||
("https://emacsninja.com/emacs.atom" v-schneidermann)
|
||||
("https://feeds.feedburner.com/InterceptedWithJeremyScahill" j-scahill)
|
||||
("https://feeds.feedburner.com/InterceptedWithJeremyScahill"
|
||||
j-scahill)
|
||||
("https://frame.work/fr/fr/blog.rss" framework)
|
||||
("https://nullprogram.com/feed/" c-wellons)
|
||||
("https://oremacs.com/atom.xml" o-krehel)
|
||||
|
Loading…
Reference in New Issue
Block a user