emacs.d/bundle/bundle--latex.el
2023-08-27 16:54:56 +02:00

87 lines
3.3 KiB
EmacsLisp

;; Org-mode LaTeX export settings
(require 'ox-latex)
;; Add custom LaTeX packages
(setq org-latex-packages-alist '(("" "listings")
("" "booktabs")
("AUTO" "polyglossia" t ("xelatex" "lualatex"))
("" "grffile")
("" "unicode-math")
("" "xcolor")))
;; Define the process to convert Org to PDF using XeLaTeX
(setq org-latex-pdf-process '("latexmk -xelatex -shell-escape -quiet -f %f"))
;; Set the compiler to XeLaTeX
(setq org-latex-compiler "xelatex")
;; Enable listings and other table-related features
(setq org-latex-listings t)
(setq org-latex-tables-booktabs t)
(setq org-latex-images-centered t)
;; Customize the appearance of listings (source code blocks)
(setq org-latex-listings-options
'(("basicstyle" "\\ttfamily")
("showstringspaces" "false")
("keywordstyle" "\\color{blue}\\textbf")
("commentstyle" "\\color{gray}")
("stringstyle" "\\color{green!70!black}")
("stringstyle" "\\color{red}")
("frame" "single")
("numbers" "left")
("numberstyle" "\\ttfamily")
("columns" "fullflexible")))
;; Set the input encoding
(setq org-latex-inputenc-alist '((\"utf8\" . \"utf8x\")))
;; Define custom LaTeX class with specific formatting
(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes
'("koma-general"
"\\documentclass[a4paper,10pt,captions=tableheading,twoside=false]{scrartcl}
\\linespread{1.25}
\\usepackage{fontspec}
\\defaultfontfeatures{Mapping=tex-text, RawFeature={+zero}}
\\setmainfont{Noto Sans}[BoldFont=*-Medium,ItalicFont=*-Italic]
\\setsansfont{Noto Sans}[BoldFont=*-Medium,ItalicFont=*-Italic]
\\setmonofont{Noto Sans Mono}[BoldFont=*-Medium,Scale=0.8]
\\usepackage{geometry}
\\geometry{a4paper,left=2cm,right=2cm,top=1.6cm,bottom=1.6cm}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\fancyhf{}
\\fancyhead[L]{\\leftmark} % Left header
\\fancyhead[R]{\\thepage} % Right header"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
;; Set default LaTeX class
(setq org-latex-default-class "koma-general")
;; Load KOMA letter support
(eval-after-load 'ox '(require 'ox-koma-letter))
;; TeX mode settings for editing .tex files
(setq TeX-auto-save t) ; Enable auto-save
(setq TeX-electric-math (cons "$" "$")) ; Shortcut for math mode
(if (eq system-type 'windows-nt)
(progn
(setq TeX-view-program-list '(("SumatraPDF" "SumatraPDF.exe %o")))
(setq TeX-view-program-selection '((output-pdf "SumatraPDF"))))
(setq TeX-view-program-selection '((output-pdf "Evince"))))
(setq TeX-source-correlate-start-server t) ; Enable source-correlate
(setq TeX-master nil) ; Default master file
(setq TeX-engine 'xetex) ; Set engine to XeTeX
(setq TeX-command-extra-options "-shell-escape") ; Allow shell escape
(use-package tex
:defer t
:ensure auctex
:hook ((LaTeX-mode . turn-on-reftex)
(LaTeX-mode . flyspell-mode)
(LaTeX-mode . LaTeX-math-mode)))