emacs.d/bundle/bundle--latex.el

81 lines
3.1 KiB
EmacsLisp
Raw Normal View History

2023-08-25 16:38:06 +02:00
;; Org-mode LaTeX export settings
2023-06-09 08:37:40 +02:00
(require 'ox-latex)
2023-08-25 16:38:06 +02:00
;; Add custom LaTeX packages
2023-06-09 08:37:40 +02:00
(setq org-latex-packages-alist '(("" "listings")
("" "booktabs")
("AUTO" "polyglossia" t ("xelatex" "lualatex"))
("" "grffile")
("" "unicode-math")
("" "xcolor")))
2023-08-25 16:38:06 +02:00
;; Define the process to convert Org to PDF using XeLaTeX
2023-06-09 08:37:40 +02:00
(setq org-latex-pdf-process '("latexmk -xelatex -shell-escape -quiet -f %f"))
2023-08-25 16:38:06 +02:00
;; Set the compiler to XeLaTeX
2023-06-09 08:37:40 +02:00
(setq org-latex-compiler "xelatex")
2023-08-25 16:38:06 +02:00
;; Enable listings and other table-related features
2023-06-09 08:37:40 +02:00
(setq org-latex-listings t)
(setq org-latex-tables-booktabs t)
2023-06-09 18:45:05 +02:00
(setq org-latex-images-centered t)
2023-06-09 08:37:40 +02:00
2023-08-25 16:38:06 +02:00
;; Customize the appearance of listings (source code blocks)
2023-06-09 08:37:40 +02:00
(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")
2023-06-09 08:37:40 +02:00
("columns" "fullflexible")))
2023-08-25 16:38:06 +02:00
;; Set the input encoding
2023-06-09 08:37:40 +02:00
(setq org-latex-inputenc-alist '((\"utf8\" . \"utf8x\")))
2023-08-25 16:38:06 +02:00
;; Define custom LaTeX class with specific formatting
2021-10-17 10:29:25 +02:00
(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes
2023-06-09 08:37:40 +02:00
'("koma-general"
2023-08-21 06:36:09 +02:00
"\\documentclass[a4paper,10pt,captions=tableheading,twoside=false]{scrartcl}
2023-06-09 08:37:40 +02:00
\\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]
2023-07-31 16:40:06 +02:00
\\usepackage{geometry}
2023-08-08 17:20:40 +02:00
\\geometry{a4paper,left=2cm,right=2cm,top=1.6cm,bottom=1.6cm}
2023-06-09 08:37:40 +02:00
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\fancyhf{}
\\fancyhead[L]{\\leftmark} % Left header
\\fancyhead[R]{\\thepage} % Right header"
2021-10-17 10:29:25 +02:00
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
2023-06-09 08:37:40 +02:00
2023-08-25 16:38:06 +02:00
;; Set default LaTeX class
2023-06-09 08:37:40 +02:00
(setq org-latex-default-class "koma-general")
2023-08-25 16:38:06 +02:00
;; Load KOMA letter support
(eval-after-load 'ox '(require 'ox-koma-letter))
2023-08-25 16:38:06 +02:00
;; TeX mode settings for editing .tex files
(use-package tex-mode
:ensure auctex
:mode ("\\.tex\\$" . latex-mode)
:custom
(TeX-auto-save t) ; Enable auto-save
(TeX-electric-math (cons "$" "$")) ; Shortcut for math mode
(TeX-view-program-selection '((output-pdf "Evince"))) ; PDF viewer
(TeX-source-correlate-start-server t) ; Enable source-correlate
(TeX-master nil) ; Default master file
(TeX-engine 'xetex) ; Set engine to XeTeX
(TeX-command-extra-options "-shell-escape")) ; Allow shell escape