From 146f6b1d2b3d6d679ee7081e5a38d990ed0ece89 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Thu, 14 Apr 2022 21:06:17 +0200 Subject: [PATCH] clean up latex article preamble --- lisp/my/my-org-article.el | 1077 +++++++++++++++-------------- settings/bibliography-settings.el | 9 +- settings/org-settings.el | 90 +-- 3 files changed, 602 insertions(+), 574 deletions(-) diff --git a/lisp/my/my-org-article.el b/lisp/my/my-org-article.el index d3a4ec5e..f9db07c4 100644 --- a/lisp/my/my-org-article.el +++ b/lisp/my/my-org-article.el @@ -18,15 +18,53 @@ ;; article-latex is based on latex ;; article-html is based on tufte-html +;; KEYWORDS are set in (org-export-define-derived-backend ... :options-alist + ;; internal ;; `translate-alist' defines Org export function with own function +;; TODO: org-ref cite version 3 not working, the tex file still has +;; the from cite:&... -> \cite{&...} +;; OR? org - oc-biblatex.el +;; using #+CITE_EXPORT: + ;;; Code: (require 'ob-latex) (require 'ob-gnuplot) (require 'ox-latex) (require 'ox-tufte) +;; add to general org variables, so that is works also to latex snippets, preview +(add-to-list 'org-latex-default-packages-alist "\\newcommand{\\ti}[1]{_\\mathrm{#1}}" t) ;; tiefstellen, Index +(add-to-list 'org-latex-default-packages-alist "\\newcommand{\\ho}[1]{^\\mathrm{#1}}" t) ;; hochstellen +(add-to-list 'org-latex-default-packages-alist "\\newcommand*{\\rom}[1]{\\mathrm{\\romannumeral #1}}" t) ;; \rom{2} -> ii +(add-to-list 'org-latex-default-packages-alist "\\makeatletter\\newcommand*{\\Rom}[1]{\\mathrm{\\expandafter\\@slowromancap\\romannumeral #1@}}\\makeatother" t) ;; \Rom{2} -> II +(add-to-list 'org-latex-default-packages-alist '("" "mathtools" t) t) ;; line underneath with text \\underbracket[1pt][0pt]{bla}_\\text{blo} +(add-to-list 'org-latex-default-packages-alist "\\newcommand\\Dfrac[2]{\\dfrac{\\displaystyle #1}{\\displaystyle #2}}" t) +(add-to-list 'org-latex-default-packages-alist "\\newcommand{\\slfrac}[2]{\\left.#1\\middle/#2\\right.}" t) +(add-to-list 'org-latex-default-packages-alist '("" "xfrac" t) t) ;; defines \sfrac[]{}[]{} +(add-to-list 'org-latex-default-packages-alist '("" "nicefrac" t) t) +(add-to-list 'org-latex-default-packages-alist '("" "faktor" t) t) +(add-to-list 'org-latex-default-packages-alist "\\DeclareDocumentCommand{\\Faktor}{s m O{0.5} m O{-0.5}}{% + \\setbox0=\\hbox{\\scalebox{0.8}{\\ensuremath{#2\\vphantom{1}}}}% + \\setbox1=\\hbox{\\ensuremath{\\diagup}}% + \\setbox2=\\hbox{\\scalebox{0.8}{\\ensuremath{#4}}}% + \\raisebox{#3\\ht1}{\\usebox0}% + \\mkern-5mu\\ifthenelse{\\equal{#1}{\\BooleanTrue}}% + {\\diagup}% + {\\rotatebox{-44}{\\rule[#5\\ht2]{0.4pt}{-#5\\ht2+#3\\ht0+\\ht0}}}% + \\mkern-4mu% + \\raisebox{#5\\ht2}{\\usebox2}% +}" t) ;; http://tex.stackexchange.com/questions/27591/extending-the-faktor-package/27735#27735" +;; also added to `my-org-article-latex-default-packages-alist' + +;; convert table #+name: glossary to \newglossaryentry to latex_header_extra +(add-hook 'org-export-before-parsing-hook + 'org-ref-glossary-before-parsing) +;; convert table #+name: acronyms to \newacronym to latex_header_extra +(add-hook 'org-export-before-parsing-hook + 'org-ref-acronyms-before-parsing) + ;; General @@ -106,17 +144,11 @@ ;; MACRO https://orgmode.org/manual/Macro-Replacement.html (add-to-list 'org-export-global-macros - '("kbd" . "@@html:$1@@")) + '("kbd" . "@@html:$1@@@@latex:\\keys{$1}@@") t) +;; (delete '("kbd" . "@@html:$1@@") org-export-global-macros) (add-to-list 'org-export-global-macros '("color" . "@@html:$2@@@@latex:\\textcolor[HTML]{$1}{$2}@@")) -;; ACRONYM -(add-to-list - 'org-export-global-macros - '("ac" . "@@html:$1@@@@latex:\ac{$1}@@")) -(add-to-list - 'org-export-global-macros - '("acf" . "@@html:$1@@@@latex:\acf{$1}@@")) ;; QUOTATION ;;; quotation mark (auto language, html using main language) (add-to-list @@ -139,6 +171,59 @@ '("ruby" . "@@html:$1($2)@@@@latex:\\ruby{$1}{$2}@@")) ;; LaTeX + +;; TODO: can be removed, replaced by my-string-insert-after-nth-newline +(defun my-string-insert-after-first-newline (text parasite) + "insert a PARASITE string (and a newline character) into TEXT after +first newline and returns the new text." + (let ((textarray (split-string text "\n" nil))) + (concat (car textarray) "\n" + parasite "\n" + (string-join (cdr textarray) "\n")))) +(defun my-split (list count) + "Slit list at (after) COUNT element and return list containing both +sub lists." + ;; Example: + ;; (split '(a b c d e f g h i k) 3) -> ((a b c) (d e f g h j k)) + ;; https://codereview.stackexchange.com/a/179682 + (values (subseq list 0 count) (nthcdr count list))) +(defun my-string-insert-after-nth-newline (text parasite nth) + "insert a PARASITE string (and a newline character) into TEXT after +NTH newline and returns the new text." + (let* ((textarraysplit (my-split (split-string text "\n" nil) nth))) + (concat (string-join (car textarraysplit) "\n") "\n" + parasite "\n" + (string-join (cadr textarraysplit) "\n")))) +(defun my-org-article-latex-appendix (headline backend info) + "Insert a appendix before the heading if property appendix is non-nil. +Uses function `my-org-headline-string-element' and +`my-string-insert-after-nth-newline' with nth equal 2. +A 'normal' looks like: + \\section{Appendix} + \\label{sec:org0069643} +Currently only one i.e. A.x is possible." + ;; headline will have all the content and children, so the string after is at the end of the section + (when (org-export-derived-backend-p backend 'latex) + (let ((elmnt (my-org-headline-string-element headline backend info))) + (when (and elmnt (org-element-property :APPENDIX elmnt)) + (concat + (my-string-insert-after-nth-newline + headline + "\\markboth{\\nameappendix}{\\nameappendix} +\\begin{mtchideinmaintoc}[-1] +\\setcounter{section}{0} +\\renewcommand{\\thesection}{A} +\\setcounter{subsection}{0} +\\setcounter{figure}{0} +\\setcounter{table}{0} +\\sectiontoc" 2) + ;; %\\renewcommand{\\thesection}{\\Alph{section}} % will be A.x but points to 1.x + ;; %\\renewcommand{\\thesubsection}{A\\arabic{subsection}} + ;; %\\renewcommand{\\thetable}{A\\arabic{table}} + "\\end{mtchideinmaintoc}"))))) +(add-to-list 'org-export-filter-headline-functions + 'my-org-article-latex-appendix) + ;;; Function Declarations (defvar my-org-article-latex-default-packages-alist) (defvar my-org-article-latex-packages-alist) @@ -149,10 +234,12 @@ (defvar my-org-article-latex-header-extra) (defvar my-org-article-latex-opening) (defvar my-org-article-latex-closing) +(defvar my-org-article-latex-draft) (defvar my-org-article-latex-references) (defcustom my-org-article-latex-references "" "") +;; see ox-latex function org-export-define-backend (org-export-define-derived-backend 'article-latex 'latex :menu-entry @@ -167,17 +254,22 @@ (org-open-file (my-org-article-latex-export-to-pdf nil s v b))))))) :options-alist - '((:headline-levels nil "H" my-org-article-export-headline-levels) + '(;; (:PROPERTY-NAME KEYWORD OPTION DEFAULT BEHAVIOR) see `org-export-options-alist' + (:headline-levels nil "H" my-org-article-export-headline-levels) (:with-sub-superscript nil "^" my-org-article-export-with-sub-superscripts) (:with-toc nil "toc" my-org-article-export-with-toc) + ;; ox-latex (:latex-class "LATEX_CLASS" nil my-org-article-latex-default-class t) (:latex-class-options "LATEX_CLASS_OPTIONS" nil my-org-article-latex-default-class-options t) (:latex-header "LATEX_HEADER" nil my-org-article-latex-header newline) (:latex-header-extra "LATEX_HEADER_EXTRA" nil my-org-article-latex-header-extra newline) + (:latex-hyperref-template nil nil my-org-article-latex-hyperref-template t) (:latex-compiler "LATEX_COMPILER" nil my-org-article-latex-compiler t) + ;; custom (:article-closing "CLOSING" nil my-org-article-latex-closing newline) (:article-opening "OPENING" nil my-org-article-latex-opening newline) - (:article-references "REFERENCES" nil my-org-article-latex-references newline)) + (:article-draft nil "draft" my-org-article-latex-draft t) ;; toogle (nil/t) to activate draft visuals, see :draft in `my-org-article-latex-template-plist' + (:article-references "REFERENCES" nil my-org-article-latex-references newline)) ;; TODO not installed yet, maybe using oc-biblatex? :translate-alist '((template . my-org-article-latex-template))) @@ -365,48 +457,72 @@ \\usebibmacro{date+extrayear}} \\addbibresource{references.bib} " - "Used in `my-org-article-latex-lang-template-plist' + "Used in `my-org-article-latex-template-plist' points to references.bib") -(defvar my-org-article-latex-lang-template-plist +(defvar my-org-article-latex-template-plist (list + :draft "\\setlength{\\overfullrule}{5pt}" + ;; LANG REPLACEMENTS :documentclass-en "english" :documentclass-de "ngerman" - ;; FONTS + ;;; FONTS :babel-en "\\usepackage[english]{babel}" :babel-de "\\usepackage[ngerman]{babel}" :fontspec-en "" :fontspec-ja "\\usepackage{luatexja-fontspec} % add japanese support using lualatex compiler" :ruby-en "" :ruby-ja "\\usepackage[CJK,overlap]{ruby} % support for FURIGANA - japanese" - ;; REFERENCES + ;;; REFERENCES :biblatex-en my-org-article-latex-header-biblatex :biblatex-de-rott "" :csquotes-en "\\usepackage[autostyle]{csquotes}" :csquotes-de "\\usepackage[autostyle,german=quotes]{csquotes}" - ;; APPENDIX + ;;; APPENDIX :mtcselectlanguage-en "" :mtcselectlanguage-de "\\mtcselectlanguage{german}" - ;; LISTINGS lstlistingname for the caption of listings and lstlistlistingname for the table of listings - :lstlistingname-en "" + ;;; LISTINGS lstlistingname for the caption of listings and lstlistlistingname for the table of listings + :lstlistingname-en "\\renewcommand{\\lstlistlistingname}{List of Listings}" :lstlistingname-de "\\renewcommand{\\lstlistingname}{Programmausdruck}\\renewcommand{\\lstlistlistingname}{Programmausdrucke}" ) - " -:documentclass-xx used in `my-org-article-latex-default-class-options' -all other in `my-org-article-latex-header' -template replacements in `my-org-article-latex-lang-template-value' -IMPORTANT en version must be defined") + "Replacements. +:documentclass-xx used in +`my-org-article-latex-default-class-options' all other in +`my-org-article-latex-header' template replacements in +`my-org-article-latex-template-value' IMPORTANT an 'en' version +must be defined. This is the fallback for language +replacements.") (defcustom my-org-article-latex-default-class-options - "[paper=a4,fontsize=11pt,DIV=12,BCOR=10mm,headsepline,<>,captions=tableheading,version=first,bibliography=totoc,dvipsnames]" + ;; DIV: Satzspiegel + ;; BCOR: Bindungskorrektur + ;; captions: correct spacing for captions ABOVE the table + ;; bibliography: add to toc + ;; %titlepage: first page, cover page (invoking \maketitle) + ;; %draft: display a block at the end of a line, which is too long (bad line break) + ;; dvipsnames: colors + "\ +[ + paper=a4, + fontsize=11pt, + DIV=12, + BCOR=10mm, + headsepline, + <>, + captions=tableheading, + version=first, + bibliography=totoc, + dvipsnames, +]" "The default LaTeX class options. Replaces <<...>> with values defined in -`my-org-article-latex-lang-template-plist'" +`my-org-article-latex-template-plist'" :group 'my-org-export-article :type '(string :tag "LaTeX class")) (add-to-list 'org-latex-classes + ;; (numbered-section . unnumbered-section) '("koma-article" "\\documentclass{scrartcl}" ("\\cleardoublepage\\section{%s}\\thispagestyle{plain}" . "\\def\\my_org_article_section{%s}\\cleardoublepage\\section*{\\my_org_article_section}\\phantomsection\\addcontentsline{toc}{section}{\\my_org_article_section}\\thispagestyle{plain}") ("\\subsection{%s}" . "\\def\\my_org_article_subsection{%s}\\subsection*{\\my_org_article_subsection}\\phantomsection\\addcontentsline{toc}{subsection}{\\my_org_article_subsection}") @@ -415,6 +531,17 @@ Replaces <<...>> with values defined in ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) (defcustom my-org-article-latex-header + ;; see also `my-org-article-latex-default-packages-alist' + "\ +<> +<> +<> +<> +\\def\\nameappendix{Appendix} +<> +<> +" "Inserted after `my-org-article-latex-default-packages-alist'.") +(defcustom my-org-article-latex-header-bak " %%% %%% ARTICLE @@ -437,11 +564,9 @@ Replaces <<...>> with values defined in %%% %%% COLORS %%% -\\usepackage{xcolor} \\usepackage{colortbl} \\xdefinecolor{navyblue}{rgb}{0,0.35,0.62} % links, \\everydisplay: -\\definecolor{darkblue}{rgb}{0,0.15,0.35} \\definecolor{darkred}{rgb}{0.88,0.16,0.17} \\definecolor{dkgreen}{rgb}{0,0.6,0} \\definecolor{gray}{rgb}{0.5,0.5,0.5} @@ -465,95 +590,16 @@ Replaces <<...>> with values defined in %\\twocoltrue \\twocolfalse% -\\special{papersize=210mm,297mm} -% ----------------------------------------- -% Allgemeine Seiten-Abstände und Einstellungen -% ----------------------------------------- -% Hälfte der Schriftgröße 12pt -\\setlength{\\parskip}{6pt} -% kein einrücken -\\setlength{\\parindent}{0pt} -\\setlength{\\textheight}{22.5cm} -%\\usepackage[a4paper, top=3cm, left=3.5cm, right=2.8cm]{geometry} -%\\setlength{\\marginparwidth}{1.5cm} % Raum für Randnotiz -% Raum für Randnotiz -\\setlength{\\marginparwidth}{0pt} -% muss vor hyperref -\\usepackage{setspace} -% Zeilenabstand, \\doublespacing, \\singlespacing -\\onehalfspacing% - -\\KOMAoptions{DIV=last} -% Nach ändern der Schriftart von KOMA-Script ganz bequem den Satzspiegel neu berechnen lassen. -\\recalctypearea% - -%keine einzelnen Seiten eines Absatzes oben oder unten auf einer Seite -\\clubpenalty=10000 -\\widowpenalty=10000 -\\displaywidowpenalty=10000 - -% Fix overful hboxes automatically: -% allg., Stand. 200, defensiver 2000 -%\\tolerance=2000 -%10pt% im Fall, Stand. 0, besser als \\tolerance -\\emergencystretch=6pt -%\\hbadness=1000 % Warnungsausgabe, Stand. 1000 -\\setlength{\\overfullrule}{5pt} - -% global oder lokal Silbentrennung verbieten -%\\pretolerance=10000 % or/the same result? \\hyphenpenalty=10000 - -% Befehle: -%\\newline -%\\linebreak - -% muss vor tocstyl -\\usepackage{pdfpages} -\\usepackage{pdflscape} % Verzeichnis -% package tocstyle obsolete, possible supported packages like tocbasic or scrwfile -% https://tex.stackexchange.com/questions/565279/missing-tocstyle-sty-file -%\\usepackage{tocstyle} % Obsolete, tocstyle -\\usepackage{tocbasic} -\\usepackage{scrwfile} \\iftwocol% \\usepackage[toc]{multitoc} \\renewcommand*{\\multicolumntoc}{2} \\setlength{\\columnseprule}{0.5pt} \\fi -%\\usetocstyle{allwithdot} % Obsolete, tocstyle -\\usepackage{tocloft} -\\setlength{\\cftbeforefigskip}{0ex} -% first: pnumwidth, second: margin, default: 1.55em and 2.55em -\\cftlocalchange{toc}{2em}{2.55em} -% section toc -% minitoc does not work with koma script therefore: %TODO clean old minitoc (and \\sectoc commmand) stuff, there is also a \\chaptertoc version online -\\makeatletter -\\newif\\ifusesectiontoc% Switch to tell \\addtocentrydefault to not only make entries to the toc-file but also to the current section-toc-file -\\newcommand*{\\sectiontoc}{% new command to generate and show a section toc - \\usesectiontoctrue% switch on section-toc-entries - \\edef\\ext@subtoc{toc\\thesection}% extension of the section-toc-file, e.g., toc1.1 - \\expandafter\\DeclareNewTOC\\expandafter{\\ext@subtoc}% declare a new toc file - \\begin{minipage}{.9\\linewidth} - \\value{tocdepth}=\\subsectiontocdepth% we want entries down to subsection - \\expandafter\\listoftoc\\expandafter*\\expandafter{\\ext@subtoc}% show the toc without any heading - \\end{minipage}\\par - \\bigskipa\\noindent% add some vertical space after the toc and do not indent the following text -} -\\usepackage{xpatch} -\\xapptocmd\\addtocentrydefault{% patch the KOMA-Script's generic toc entry generator - \\ifusesectiontoc% if section toc entries should be generated - \\expandafter\\tocbasic@addxcontentsline\\expandafter{\\ext@subtoc}{#1}{#2}{#3}% do it - \\fi -}{}{} -\\xpretocmd\\section{\\usesectiontocfalse}{}{}% automatically switch of section toc entries at start of every \\section -\\makeatother - -%\\usepackage{bigfoot} % footnote % debug the box warnings @@ -585,22 +631,7 @@ Replaces <<...>> with values defined in % ----------------------------------------- % Schrift % ----------------------------------------- -% Schöneres Schriftpacket für LateX -\\usepackage{lmodern} -% Dominanz hinten -<> -% \\usepackage[utf8]{inputenc} % latin1, utf8, ansinew, latin2 -\\usepackage[utf8]{luainputenc} -\\usepackage[T1]{fontenc} -<> -\\DeclareUnicodeCharacter{2009}{\\,} % convert unicode to latex command, thin-space - -% bessere Schrifte -% sfmath, % sans-serif slanted fonts -% slantedGreeks, % Uppercase greeks are slanted -% do not load textcomp again -\\usepackage[notextcomp]{kpfonts} \\usepackage[scale=0.95]{opensans} % hyphenatable letterspacing, underlining and some derivatives such as overstriking and highlighting, soul @@ -618,23 +649,6 @@ Replaces <<...>> with values defined in \\usepackage[version=3]{mhchem} \\usepackage{xparse} -% Befehle: -% change family of the font. If possible other aspects – like the series or the shape – are preserved. -% \\textrm (\\rmfamily) Normal font (default). -% \\textsf (\\sffamily) Sans serif. -% \\texttt (\\ttfamily) Typewriter. -% \\emph Emphasis (toggles between \\textit and \\textrm) - -% \\textmd (\\mdseries) Medium weight (default). The opposite of boldface. -% \\textbf (\\bfseries, \\bf) Bold weight. - -% \\textup (\\upshape) Upright (default). The opposite of slanted. -% \\textit (\\itshape) Italic. -% \\textsl (\\slshape) Slanted. -% \\textsc (\\scshape) Small caps. - -% \\textnormal (\\normalfont) Main document font. - % \\tiny \\scriptsize \\footnotesize \\small % \\normalsize (default) % \\large \\Large \\LARGE \\huge \\Huge @@ -653,78 +667,6 @@ Replaces <<...>> with values defined in \\renewcommand{\\sout}[1]{\\st{#1}} <> -%%% -%%% RUNNINGTITLE -%%% -% ----------------------------------------- -% Seitenstil für lebende Kolumnentitel -% ----------------------------------------- -%\\pagestyle{headings} -\\usepackage{fancyhdr} -\\pagestyle{fancy} -\\fancyhead{} -\\fancyfoot{} -% for twoside option: LE,RO -\\fancyhead[RO]{\\slshape \\leftmark}% -\\fancyfoot[C]{--~\\thepage~--} -%\\fancyfoot[RO] {\\thepage} -\\renewcommand{\\headrulewidth}{0.4pt} -\\renewcommand{\\footrulewidth}{0pt} -\\newlength\\FHoffset% -% Offset des Headers 0: bündig mit text -\\setlength\\FHoffset{0cm} -\\addtolength\\headwidth{1\\FHoffset} -\\fancyheadoffset{\\FHoffset} -% these lengths will control the headrule trimming to the left and right -\\newlength\\FHleft% -\\newlength\\FHright% -% here the trimmings are controlled by the user -\\setlength\\FHleft{-1cm} -\\setlength\\FHright{-1cm} -% The new definition of headrule that will take into acount the trimming(s) -\\newbox\\FHline% -\\setbox\\FHline=\\hbox{\\hsize=\\paperwidth% - \\hspace*{\\FHleft}% - \\rule{\\dimexpr\\headwidth-\\FHleft-\\FHright\\relax}{\\headrulewidth}\\hspace*{\\FHright}% -} -\\renewcommand\\headrule{\\vskip-.7\\baselineskip\\copy\\FHline} - -% keine Linien auf Bilderseiten! -\\renewcommand{\\headrulewidth}{\\iffloatpage{0pt}{0.4pt}} - -\\renewcommand{\\sectionmark}[1]{ -\\markboth{\\thesection{} #1}{\\thesection{} #1} -} -\\renewcommand{\\subsectionmark}[1]{ -\\markright{\\thesubsection{} #1} -} - -\\fancypagestyle{plain}{ -\\fancyhead{} -\\fancyfoot{} -\\renewcommand{\\headrulewidth}{0.4pt} -\\fancyfoot[C]{--~\\thepage~--} -%\\fancyfoot[RO] {\\thepage} -} - -% must be set between an header and text, direct before the first paragraph, and must be compiled at least twice -\\newcommand{\\sectionheader}{% - \\thispagestyle{plain}% - \\begin{tikzpicture}[remember picture, overlay]% - \\node[shift={(0 cm,-2.8cm)}] at (current page.north west){% - \\begin{tikzpicture}[remember picture, overlay]% - \\node[shift={(2.8,0)},right] {\\TITLE\\ -- \\SUBTITLE};% - \\end{tikzpicture}% - };% - \\node[shift={(0 cm,-2.8cm)}] at (current page.north east){% - \\begin{tikzpicture}[remember picture, overlay]% - \\node[shift={(-2.8,0)},left] {\\AUTHOR};% - \\end{tikzpicture}% - };% - % Draw a page border - % \\draw (current page.north west) rectangle (current page.south east);% - \\end{tikzpicture}% -} %%% %%% REFERENCES @@ -732,10 +674,6 @@ Replaces <<...>> with values defined in % ----------------------------------------- % Literatur % ----------------------------------------- -<> - -%babel, % 'babel' depreciated - autostyle -<> \\expandafter\\def\\expandafter\\quote\\expandafter{\\quote\\small} % Schriftverkleinerung in quote-Umgebung @@ -970,39 +908,6 @@ Replaces <<...>> with values defined in %quote '+' %line_max 255 -%%% -%%% GLOSSARIES -%%% -\\usepackage[% - %nowarn, - %nomain, - %toc=true, % Eintrag im Inhaltsverzeichnis - %style=altlist, % altlist: Beschreibung beginnt in neuer Zeile - nonumberlist, % keine Seitenzahlen anzeigen - nogroupskip, % keine extra Abstand bei Buchstabenwechsel - %acronym=true, % ein Abkürzungsverzeichnis erstellen - section=section, % im Inhaltsverzeichnis auf section-Ebene erscheinen, subsection ... - %description, % n changes the definition of \\newacronym to allow a description - %makeindex, - %xindy={language=german-duden,codepage=utf8} % mit makeglossaries.exe ? - %hyperfirst=false, % -]{glossaries} - -\\usepackage[nonumberlist, nogroupskip, section=section,]{glossaries} - -%Den Punkt am Ende jeder Beschreibung deaktivieren -\\renewcommand*{\\glspostdescription}{} -% to refer \\ref{glo:...} -\\renewcommand*{\\glsautoprefix}{glo:} -%Allgemeine definition -%\\newglossary[⟨log-ext⟩]{⟨name⟩}{⟨in-ext⟩}{⟨out-ext⟩}{⟨title⟩}[⟨counter⟩] -\\newcommand{\\dictentry}[2]{% - \\newglossaryentry{#1}{name=#1,description={#2}}% - \\glslink{#1}{}% -} - -%\\input{Glossary.tex} -%\\makeglossaries% %%% %%% FIGURES @@ -1012,24 +917,10 @@ Replaces <<...>> with values defined in % ----------------------------------------- \\usepackage{float} \\usepackage{floatflt} -\\usepackage[ - font=small, % footnotesize, small - labelfont={bf,up,sf}, - %textfont={it,up}, - justification=raggedright, % justified - singlelinecheck=false, - %format=plain, - %indention=0cm, -]{caption} -%\\addtokomafont{caption}{\\small} % Bildunterschrift Größe \"small\" -%\\setkomafont{captionlabel}{\\sffamily\\bfseries} % das Label wird serifenlos und fett + \\usepackage{subcaption} \\usepackage{tablefootnote} -%%%%%% THIS PASSAGE MAKES THE TABLE AND FIGURE COUNT TO 1.1 or 4.1 INSTEAD OF 1,2,3,4... -%\\usepackage{chngcntr} -%\\counterwithin{figure}{section} -\\counterwithin{table}{section} % ----------------------------------------- @@ -1091,21 +982,6 @@ Replaces <<...>> with values defined in % \\includesvg[2]{filename} % \\end{center} -% the following eps function is unsure - copy from web !!! -%\\usepackage{epstopdf} -%\\newcommand{\\includeps}[2][\\undefined]{% -% \\immediate\\write18{inkscape2tex.py -i #2 -m latex-eps}% -% \\ifx#1\\undefined% -% \\global\\let\\svgwidth\\undefined% -% \\else% -% \\def\\svgwidth{#1}% -% \\fi% -% \\IfFileExists{#2.eps_tex}{% -% \\input{#2.eps_tex}% -% }{% -% {\\color{red} FILE #2.eps_tex NOT FOUND.}% -% }% -%}% % Diagramme @@ -1115,13 +991,12 @@ Replaces <<...>> with values defined in % Tabellen % ----------------------------------------- %\\usepackage{rotating} % rotated text, vertical: \\begin{sideways} ... \\end{sideways} -% fuer Tabellen ueber mehrere Seiten -\\usepackage{longtable} + % fuer mehrspaltigen Text auf einer Seite \\usepackage{multicol} % fuer mehrreihigen Text auf einer Seite \\usepackage{multirow} -\\usepackage{booktabs} + \\usepackage{array} \\usepackage{eqnarray} \\newcolumntype{P}[1]{>{\\raggedright\\arraybackslash}p{#1}} @@ -1130,58 +1005,15 @@ Replaces <<...>> with values defined in % Anzahl Zeilen, Weite, Inhalt \\newcommand{\\multirowr}[3]{\\multirow{#1}{*}{\\parbox{#2}{\\raggedright #3}}} -%\\usepackage{fancybox} % besondere Rahmen, Schatten +\\usepackage{spreadtab} % Rechenmöglichkeit in Tabellen -%\\begin{center} -%\\resizebox{0.95\\textwidth}{!}{% -%\\begin{tabular} -%... -%\\end{tabular}} -%\\end{center} -% Zahlenformatierung -\\usepackage[autolanguage]{numprint} -% Rechenmöglichkeit in Tabellen -\\usepackage{spreadtab} -%%% -%%% LISTS -%%% -% ----------------------------------------- -% Aufzählungen -% ----------------------------------------- -\\makeatletter -\\newcommand*{\\rom}[1]{\\mathrm{\\romannumeral #1}} -\\newcommand*{\\Rom}[1]{\\mathrm{\\expandafter\\@slowromancap\\romannumeral #1@}} -\\makeatother - -\\renewcommand{\\labelitemi}{--} -% \\times -\\renewcommand{\\labelitemii}{\\(\\boldsymbol\\cdot\\)} - -% Verbesserte Enumerate-Umgebung -\\usepackage{enumerate} - -\\usepackage{enumitem} -% noitemsep -\\setlist{nosep} -% Usually a good idea -\\setlist[1]{labelindent=\\parindent} -\\setlist[itemize]{parsep=0pt,itemsep=0pt,leftmargin=*} -\\setlist[enumerate]{parsep=0pt,itemsep=0pt,leftmargin=*} %%% %%% LISTINGS %%% -\\usepackage{listingsutf8} -%\\begin{lstlisting}[numbersep=0pt,resetmargins=true] -<> -\\lstdefinestyle{custom}{ - %xleftmargin=2em, -} \\lstdefinelanguage{example}{ } -\\lstdefinelanguage{org}{ -} \\lstdefinelanguage{calc}{ } \\lstdefinelanguage{shell}{ @@ -1197,6 +1029,7 @@ Replaces <<...>> with values defined in % otherwise copy-and-paste won’t work basicstyle=\\ttfamily } +% not needed for lualatex? \\lstset{literate=% {Ö}{{\\\"O}}1 {Ä}{{\\\"A}}1 @@ -1206,115 +1039,13 @@ Replaces <<...>> with values defined in {ä}{{\\\"a}}1 {ö}{{\\\"o}}1 } -\\lstset{ - extendedchars=\\true, - inputencoding=utf8/latin1, - style=custom, - language=Matlab, - % small, footnotesize - basicstyle=\\small\\ttfamily, - % \\bfseries - keywordstyle=\\color{blue}, - % \\itshape - commentstyle=\\color{dkgreen}, - %identifierstyle=\\color{blue}, - stringstyle=\\color{mauve}, - % \\ttfamily - numberstyle=\\tiny\\color{gray}, - numbers=left, - numbersep=5pt, - %stepnumber=2, - %backgroundcolor=\\color{white}, - %frame=single,%trblTRBL,none|leftline|topline|bottomline|lines|single|shadowbox - %frameround=ffff, % tf|rf|rf|rf NE,SE,SW,NW - %rulecolor=\\color{black}, - %showspaces=false, - %showstringspaces=false, - %showtabs=false, - %float, - breaklines=true, - breakatwhitespace=true, - %breakindent=20pt, - tabsize=2, - % 2\\parskip - xleftmargin=2em, - %title=\\lstname, - %captionpos=b, % b: bottom - captionpos=t, - %belowcaptionskip=1\\baselineskip, - %texcl=true, % not with inputencoding utf/latin1 LATEX comment lines, for äöü... - %escapebegin=\\begin{arab},escapeend=\\end{arab}, - escapeinside={\\%*}{*)}, - %morekeywords={*,...}, - %deletekeywords={...}, -% auto: Listings with identical names (case sensitive!) share a line counter / or number - firstnumber=auto, -} -\\newcommand{\\includecode}[2][c]{ - \\lstinputlisting[ - caption=#2, - escapechar=, - style=#1, - %label=DescriptiveLabel, -]{#2}} -% \\includecode{sched.c} -% \\includecode[asm]{sched.s} -% \\lstlistoflistings + %%% %%% MATH %%% -% ----------------------------------------- -% Zusatzzeichen, Mathematik, Chemie -% ----------------------------------------- -% fette Schrift, z.B. $\\boldsymbol{\\pi}$ -% Zusammenrücken: \\!, \\negmedspace, \\negthickspace -% Platz einfügen: \\, \\: \\; ~ oder \\quad und \\qquad -% mehrzeilige Grenzen, \\substack{...\\\\...} -% \\overset{}{} und \\underset{}{} setzte Formelbestandteile über- oder untereinander -% \\underbrace{a+b}_\\text{Schritt 1} -% \\overbrace{e^2 - \\pi}^\\text{Schritt 2} -\\numberwithin{equation}{section} -% Manuelle Nummerierung, z. B. 1.2 a -%\\begin{equation*} \\tag{} \\end{equation*} -%\\allowdisplaybreaks % global und lokal Anwendbar, z. B. bei underful vboxes - -%\\usepackage{fourier} -\\usepackage{mathtools} -% linie unterhalb mit text \\underbracket[1pt][0pt]{bla}_\\text{blo} - -\\newcommand\\Dfrac[2]{\\dfrac{\\displaystyle #1}{\\displaystyle #2}} -\\newcommand{\\slfrac}[2]{\\left.#1\\middle/#2\\right.} -\\usepackage{xfrac} -\\usepackage{nicefrac} -\\usepackage{faktor} -% -% http://tex.stackexchange.com/questions/27591/extending-the-faktor-package/27735#27735 -% \\newfaktor[*]{#2}[#3]{#4}[#5] -> #2/#4 -\\DeclareDocumentCommand{\\Faktor}{s m O{0.5} m O{-0.5}}{% - % Store numerator - \\setbox0=\\hbox{\\scalebox{0.8}{\\ensuremath{#2\\vphantom{1}}}}% - % Store slash / - \\setbox1=\\hbox{\\ensuremath{\\diagup}}% - % Store denominator - \\setbox2=\\hbox{\\scalebox{0.8}{\\ensuremath{#4}}}% - % Numerator - \\raisebox{#3\\ht1}{\\usebox0}% - % Slash / - \\mkern-5mu\\ifthenelse{\\equal{#1}{\\BooleanTrue}}% - % regular \\faktor slash - {\\diagup}% - % tilted rule as a slash - {\\rotatebox{-44}{\\rule[#5\\ht2]{0.4pt}{-#5\\ht2+#3\\ht0+\\ht0}}}% - \\mkern-4mu% - % Denominator - \\raisebox{#5\\ht2}{\\usebox2}% -} - % another slanted fration below at tikz -\\usepackage{eurosym} % fuer das Eurosymbol -\\DeclareUnicodeCharacter{20AC}{\\euro{}} % convert unicode character to latex command % \\usepackage[ % kann nicht mit amssymb zusammenlaufen % thinspace, @@ -1331,13 +1062,6 @@ Replaces <<...>> with values defined in \\DeclareSIUnit{\\EUR}{\\text{\\euro}} %obsolete \\usepackage[thinspace, thinqspace, squaren, Gray,]{SIunits} -% tiefstellen, Index -\\newcommand{\\ti}[1]{_\\mathrm{#1}} -% hochstellen -\\newcommand{\\ho}[1]{^\\mathrm{#1}} -%\\usepackage{mathrsfs} % use \\mathscr, Ralph Smith’s Formal Script Font -%\\usepackage{ziffer} - %Mathematische Schrifterweiterungen % use \\mathds{A} alternative zu mathbb \\usepackage{dsfont} @@ -1528,51 +1252,14 @@ Replaces <<...>> with values defined in }{\\end{array}\\endgroup} -% ----------------------------------------- -% Eigene Befehle -% ----------------------------------------- - % öffnende Winkelklammer \"\" -\\newcommand{\\<}{\\(\\langle\\)} -% schliessende Winkelklammer \"\" -\\renewcommand{\\>}{\\(\\rangle\\)} - -\\newcommand{\\bsufont}{\\normalfont\\sffamily\\upshape\\bfseries} - -\\newcommand\\TikZ{Ti\\textit kZ} -\\newcommand\\PGF{\\textsc{pgf}} - -% Technische Zeichen -\\newcommand{\\bohrtiefe}{\\scalebox{1}[0.75]{\\rotatebox[origin=ct]{-90}{\\hspace{0.2ex}$\\mapsto$}}} - %%% %%% TIKZ %%% % ----------------------------------------- % Zeichnungen % ----------------------------------------- -\\usepackage{tikz} -\\usepackage{gnuplot-lua-tikz} -% ,pgfmath -\\usepackage{pgfplots} % for \\begin{axis} -\\usepgflibrary{shapes.geometric} \\usepackage{tabularx} -\\usetikzlibrary{ - % for arrow heads - arrows, - % for manimulation of coordinates - calc, - positioning, - shapes.multipart, - %shadings, - decorations.pathmorphing, - % need package pgfplots - backgrounds, - %after pgfplots, for /pgfplots/annot/js fillColor - pgfplotsclickable, - shadows, - shadows.blur, - mindmap, -} + % based on soul % \\highlight[tikz-opts]{...} like: @@ -1942,27 +1629,367 @@ Replaces <<...>> with values defined in " "Preamble options. Text like <<...>>> will be replaced according to -`my-org-article-latex-lang-template-plist'" +`my-org-article-latex-template-plist'" :group 'my-org-export-article) (defcustom my-org-article-latex-header-extra "" "Preamble extra options." :group 'my-org-export-article) +(defcustom my-org-article-latex-hyperref-template + ;; DON't let hyperref overload the format of index and glossary. + ;; I want to do that on my own in the stylefiles for makeindex... + ;; %pdfpagelabels, + ;; pdfstartview=FitH, %% fit document to window width, {XYZ null null 1} + ;; pdfpagemode=UseNone, %% do not display thumbnails + ;; colorlinks=true, %% use true to enable colors below: + ;; pdfborder=0 0 0, %% PDF display of links, if colorlinks=false. 0 0 0: nothing. 0 0 1: default. + ;; %frenchlinks=false, %% small caps instead of colors + ;; plainpages=false, %% false for Roman and Arabian numbers + ;; hypertexnames=true, %% true for Roman and Arabian numbers; without hypertexnames it's just counting upwards; bei 4 -> iv + "\ +\\makeatletter +\\let\\@old@wrindex=\\@wrindex +\\@ifpackageloaded{hyperref}{ + \\hypersetup{%% + pdfauthor={%a}, + pdftitle={%t}, + pdfkeywords={%k}, + pdfsubject={%d}, + pdfcreator={%c}, + pdflang={%L}, + pdfproducer={LaTeX}, + pdfstartview=FitH, + pdfpagemode=UseNone, + bookmarksopen=true, + bookmarksnumbered=true, + colorlinks=true, + linkcolor=black, + filecolor=darkblue, + menucolor=darkblue, + urlcolor=darkblue, + citecolor=black, + pdfborder=0 0 0, + plainpages=false, + hypertexnames=true, + } +}{} +\\let\\@wrindex=\\@old@wrindex +\\makeatother +" + "see `org-latex-hyperref-template'" + :group 'my-org-export-article + :type '(choice (const :tag "No template" nil) + (string :tag "Format string"))) + (defcustom my-org-article-latex-default-packages-alist - '(("AUTO" "inputenc" t ("pdflatex")) - ("T1" "fontenc" t ("pdflatex")) - ("" "graphicx" t) - ("" "grffile" t) - ("" "longtable" nil) - ("" "wrapfig" nil) - ("" "rotating" nil) - ("normalem" "ulem" t) - ("" "amsmath" t) - ("" "textcomp" t) - ("" "amssymb" t) - ("" "capt-of" nil) - ("" "hyperref" nil)) + ;; additionals in `my-org-article-latex-header' babel, fontspec + '( + ;; cell is of the format + ;; ("options" "package" SNIPPET-FLAG COMPILERS) +;;; Font + ("AUTO" "inputenc" t ("pdflatex")) + ("utf8" "luainputenc" t ("lualatex")) + ("T1" "fontenc" t ("pdflatex" "lualatex")) ;; font encoding: T1: latin modern, for ö etc. as single glyph + ("" "kpfonts" t) ;; for lualatex it also needs fontenc +;;; page spacing + "\\special{papersize=210mm,297mm}" + "\\setlength{\\parskip}{6pt}" ;; half of the font size 12pt + "\\setlength{\\parindent}{0pt}" ;; no paragraph indentation + "\\setlength{\\textheight}{22.5cm}" + "\\setlength{\\marginparwidth}{1.5cm}" ;; space for margin notes" +;;; line spacing !before hyperref! + ("" "setspace" nil) ;; !before hyperref! -> env spacing e.g. used for the list of ... sections + "\\onehalfspacing" ;; set line spacing to 1.5 + "\\KOMAoptions{DIV=last}\\recalctypearea" ;; after changing font family update DIV settings + ;; overful hboxes + "\\clubpenalty=10000" + "\\widowpenalty=10000" + "\\displaywidowpenalty=10000" ;; no single paragraph on a single page (either top or bottom) + + "\\emergencystretch=6pt" ;; fix overful hboxes automatically: 10pt if needed, standard 0, better than \tolerance + ;; "\\setlength{\\overfullrule}{5pt}" ;; like draft, show a black box at the end of a overfull hbox +;;; running title + ;; "%\\pagestyle{headings}" + "\\usepackage{fancyhdr}" + "\\pagestyle{fancy}" + "\\fancyhead{}" + "\\fancyfoot{}" + ;; "% for twoside option: LE,RO" + "\\fancyhead[RO]{\\slshape \\leftmark}%" + "\\fancyfoot[C]{--~\\thepage~--}" + ;; "%\\fancyfoot[RO] {\\thepage}" + "\\renewcommand{\\headrulewidth}{0.4pt}" + "\\renewcommand{\\footrulewidth}{0pt}" + "\\newlength\\FHoffset%" + ;; "% Offset des Headers 0: bündig mit text" + "\\setlength\\FHoffset{0cm}" + "\\addtolength\\headwidth{1\\FHoffset}" + "\\fancyheadoffset{\\FHoffset}" + ;; "% these lengths will control the headrule trimming to the left and right" + "\\newlength\\FHleft%" + "\\newlength\\FHright%" + ;; "% here the trimmings are controlled by the user" + "\\setlength\\FHleft{-1cm}" + "\\setlength\\FHright{-1cm}" + ;; "% The new definition of headrule that will take into acount the trimming(s)" + "\\newbox\\FHline%" + "\\setbox\\FHline=\\hbox{\\hsize=\\paperwidth%" + " \\hspace*{\\FHleft}%" + " \\rule{\\dimexpr\\headwidth-\\FHleft-\\FHright\\relax}{\\headrulewidth}\\hspace*{\\FHright}%" + "}" + "\\renewcommand\\headrule{\\vskip-.7\\baselineskip\\copy\\FHline}" + "" + ;; "% keine Linien auf Bilderseiten!" + "\\renewcommand{\\headrulewidth}{\\iffloatpage{0pt}{0.4pt}}" + ;; "" + "\\renewcommand{\\sectionmark}[1]{" + "\\markboth{\\thesection{} #1}{\\thesection{} #1}" + "}" + "\\renewcommand{\\subsectionmark}[1]{" + "\\markright{\\thesubsection{} #1}" + "}" + ;; "" + "\\fancypagestyle{plain}{" + "\\fancyhead{}" + "\\fancyfoot{}" + "\\renewcommand{\\headrulewidth}{0.4pt}" + "\\fancyfoot[C]{--~\\thepage~--}" + ;; "%\\fancyfoot[RO] {\\thepage}" + "}" + ;; "" + ;; "% must be set between an header and text, direct before the first paragraph, and must be compiled at least twice" + "\\newcommand{\\sectionheader}{%" + " \\thispagestyle{plain}%" + " \\begin{tikzpicture}[remember picture, overlay]%" + " \\node[shift={(0 cm,-2.8cm)}] at (current page.north west){%" + " \\begin{tikzpicture}[remember picture, overlay]%" + " \\node[shift={(2.8,0)},right] {\\TITLE\\ -- \\SUBTITLE};%" + " \\end{tikzpicture}%" + " };%" + " \\node[shift={(0 cm,-2.8cm)}] at (current page.north east){%" + " \\begin{tikzpicture}[remember picture, overlay]%" + " \\node[shift={(-2.8,0)},left] {\\AUTHOR};%" + " \\end{tikzpicture}%" + " };%" + ;; " % Draw a page border" + ;; " % \\draw (current page.north west) rectangle (current page.south east);%" + " \\end{tikzpicture}%" + "}" +;;; Lists + ;; ("" "enumerate" nil) ;; already loaded? + "\\renewcommand{\\labelitemi}{--}" ;; 1st level dash instead of dot + "\\renewcommand{\\labelitemii}{\\(\\boldsymbol\\cdot\\)}" ;; 2nd level dot instead of dash + ("inline" "enumitem" nil) ;; itemize option noitemsep + "\\setlist{nosep}" ;; set noitemsep as default + "\\setlist[1]{labelindent=\\parindent}" ;; start bullets at left margins + "\\setlist[itemize]{parsep=0pt,itemsep=0pt,leftmargin=*}" + "\\setlist[enumerate]{parsep=0pt,itemsep=0pt,leftmargin=*}" +;;; Figures and Tables and Listings + ("" "float" nil) ;; adds placement H + ;; "\restylefloat{table}" ;; not needed is seems + ("\n font=small,\n labelfont={bf,up,sf},\n justification=raggedright,\n singlelinecheck=false,\n" + ;; %textfont={it,up}, %format=plain, %indention=0cm, + "caption" + nil) + "\\captionsetup[table]{skip=.5em}" + "\\captionsetup[figure]{skip=10pt}" + "\\counterwithin{figure}{section}" ;; section-wise numbering +;;; - Tables + "\\counterwithin{table}{section}" ;; section-wise numbering + ("" "booktabs" nil) ;; \toprule, \midrule, bottomrule + ("" "longtable" nil) ;; multi-page tables + ("autolanguage" "numprint" nil) ;; alignment of numbers using column type n (numbers in math) and N (numbers in text) +;;; - Lisitings + ("" "listingsutf8" nil) + "\\AtBeginDocument{\\numberwithin{lstlisting}{section}}" ;; section-wise numbering + ;; replacement of <> in `my-org-article-latex-header' + "\\lstdefinelanguage{conf}{}" + "\\lstdefinelanguage{org}{" + " morekeywords={:results, :session, :var, :noweb, :exports}," + " sensitive=false," + " morestring=[b]\"," + " morecomment=[l]{\\#}," + "}" + "\\lstset{" ;; fallback style + " extendedchars=\\true," + " inputencoding=utf8/latin1," ;; if package listingsutf8 is used + ;; " style=custom," + ;; " language=Matlab," + " basicstyle=\\small\\ttfamily," ;; small, footnotesize, scriptsize + " keywordstyle=\\color{blue}," ;; \\bfseries + " commentstyle=\\color{dkgreen}," ;; \\itshape + " stringstyle=\\color{mauve}," + " numberstyle=\\tiny\\color{gray}," ;; \\ttfamily + " numbers=left," + " numbersep=5pt," + " breaklines=true," + " breakatwhitespace=true," + " tabsize=2," + " xleftmargin=2em," ;; 2\parskip + " captionpos=t," + " escapeinside={\\%*}{*)}," + " firstnumber=auto," ;; auto: Listings with identical names (case sensitive!) share a line counter / or number + ;; " %identifierstyle=\\color{blue}," + ;; " %stepnumber=2, + ;; " %backgroundcolor=\\color{white}, + ;; " %frame=single,%trblTRBL,none|leftline|topline|bottomline|lines|single|shadowbox + ;; " %frameround=ffff, % tf|rf|rf|rf NE,SE,SW,NW + ;; " %rulecolor=\\color{black}, + ;; " %showspaces=false, + ;; " %showstringspaces=false, + ;; " %showtabs=false, + ;; " %float, + ;; " %breakindent=20pt, + ;; " %title=\\lstname, + ;; " %captionpos=b, % b: bottom + ;; " %belowcaptionskip=1\\baselineskip, + ;; " %texcl=true, % not with inputencoding utf/latin1 LATEX comment lines, for äöü... + ;; " %escapebegin=\\begin{arab},escapeend=\\end{arab}, + ;; " %morekeywords={*,...}, + ;; " %deletekeywords={...}, + "}" +;;; Glossaries + ("\n automake,\n acronym,\n nonumberlist,\n nogroupskip,\n section=section,\n" + "glossaries" nil) + ;; automake, % will run makeindex to create .gls, .acr files, + ;; (? automake or automake=true will execute at the end of the document, for lualatex we need it before the command \makeglossaries, for this using automake=immediate (https://tex.stackexchange.com/a/468877)) + ;; to create .glo and .acn with latexmk see latexmkrc file + ;; %nowarn, + ;; %nomain, + ;; %toc=true, % entry in toc + ;; %style=altlist, % altlist: description beginns in new line + ;; nonumberlist, % display no page number + ;; nogroupskip, % no extra space for change of letter + ;; acronym=true, % create a list of ancronyms + ;; section=section, % in toc appears on a section level (subsection ...) + ;; %description, % n changes the definition of \\newacronym to allow a description + ;; %makeindex, + ;; %xindy={language=german-duden,codepage=utf8} % mit makeglossaries.exe ? + ;; %hyperfirst=false, % + ;; % define an entry \\newglossary[⟨log-ext⟩]{⟨name⟩}{⟨in-ext⟩}{⟨out-ext⟩}{⟨title⟩}[⟨counter⟩] + "\\renewcommand*{\\glspostdescription}{}" ;; remove the dot at the end of every entry + "\\makeglossaries%" +;;; Glyphs & More + "\\DeclareUnicodeCharacter{2009}{\\,}" ;; convert unicode to latex command, thin-space + ("" "eurosym" t) + "\\DeclareUnicodeCharacter{20AC}{\\euro{}}" ;; convert unicode character to latex command + ("os=win" "menukeys" nil) ;; see also defined macro kbd using \keys + ;; in math mode + "\\newcommand{\\ti}[1]{_\\mathrm{#1}}" ;; 'tiefstellen' as text with better spacing, Index + "\\newcommand{\\ho}[1]{^\\mathrm{#1}}" ;; 'hochstellen' as text with better spacing + "\\newcommand*{\\rom}[1]{\\mathrm{\\romannumeral #1}}" ;; \rom{2} -> ii + "\\makeatletter\\newcommand*{\\Rom}[1]{\\mathrm{\\expandafter\\@slowromancap\\romannumeral #1@}}\\makeatother" ;; \Rom{2} -> II +;;; - COLORS + ("" "xcolor" t) + "\\definecolor{darkblue}{rgb}{0,0.15,0.35}" ;; used in hyperref, url links + "\\definecolor{dkgreen}{rgb}{0,0.6,0}" ;; used in listings + "\\definecolor{mauve}{rgb}{0.58,0,0.82}" ;; used in listings +;;; MATH custom symbols, math, chemistry + ;; bold font, e.g. $\\boldsymbol{\\pi}$ + ;; negativ space: \\!, \\negmedspace, \\negthickspace + ;; positive space: \\, \\: \\; ~ or \\quad and \\qquad + ;; multiline limits, \\substack{...\\\\...} + ;; \\overset{}{} and \\underset{}{} sets formula elements over or under each other + ;; \\underbrace{a+b}_\\text{step 1} + ;; \\overbrace{e^2 - \\pi}^\\text{step 2} + "\\numberwithin{equation}{section}" + ;; manual numbering, z. B. 1.2 a + ;; \\begin{equation*} \\tag{} \\end{equation*} + ;; \\allowdisplaybreaks % global and local usable, e.g. for underful vboxes + ;; ("" "fourier" nil) + ("" "mathtools" t) ;; line underneath with text \\underbracket[1pt][0pt]{bla}_\\text{blo} + "\\newcommand\\Dfrac[2]{\\dfrac{\\displaystyle #1}{\\displaystyle #2}}" + "\\newcommand{\\slfrac}[2]{\\left.#1\\middle/#2\\right.}" + ("" "xfrac" t) ;; defines \sfrac[]{}[]{} + ("" "nicefrac" t) + ("" "faktor" t) + ;; "% http://tex.stackexchange.com/questions/27591/extending-the-faktor-package/27735#27735" + ;; "% \\newfaktor[*]{#2}[#3]{#4}[#5] -> #2/#4" + "\\DeclareDocumentCommand{\\Faktor}{s m O{0.5} m O{-0.5}}{%" + ;; " % Store numerator" + " \\setbox0=\\hbox{\\scalebox{0.8}{\\ensuremath{#2\\vphantom{1}}}}%" + ;; " % Store slash /" + " \\setbox1=\\hbox{\\ensuremath{\\diagup}}%" + ;; " % Store denominator" + " \\setbox2=\\hbox{\\scalebox{0.8}{\\ensuremath{#4}}}%" + ;; " % Numerator" + " \\raisebox{#3\\ht1}{\\usebox0}%" + ;; " % Slash /" + " \\mkern-5mu\\ifthenelse{\\equal{#1}{\\BooleanTrue}}%" + ;; " % regular \\faktor slash" + " {\\diagup}%" + ;; " % tilted rule as a slash" + " {\\rotatebox{-44}{\\rule[#5\\ht2]{0.4pt}{-#5\\ht2+#3\\ht0+\\ht0}}}%" + " \\mkern-4mu%" + ;; " % Denominator" + " \\raisebox{#5\\ht2}{\\usebox2}%" + "}" +;;; ToC + ;; !do not wrap toc in env spacing (package setspace), this will overwrite defined skips! + ;; e.g. in \\RedeclareSectionCommand[tocbeforeskip=2.25em plus 1pt, ...]{section} + ;; ("" "tocbasic" nil) + "\\KOMAoptions{sectionentrydots=true}" + ("" "scrwfile" nil ("pdflatex")) ;; avoid trouble with the limited number of write handles ('No room for new \\write') +;;; - Section ToC (especially for appendix) + "\\makeatletter" + "\\newif\\ifusesectiontoc%" ;; Switch to tell \\addtocentrydefault to not only make entries to the toc-file but also to the current section-toc-file + "\\newcommand*{\\sectiontoc}{%" ;; new command to generate and show a section toc + " \\usesectiontoctrue%" ;; switch on section-toc-entries + " \\edef\\ext@subtoc{toc\\thesection}%" ;; extension of the section-toc-file, e.g., toc1.1 + " \\expandafter\\DeclareNewTOC\\expandafter{\\ext@subtoc}%" ;; declare a new toc file + " \\begin{minipage}{.9\\linewidth}" + " \\value{tocdepth}=\\subsectiontocdepth%" ;; we want entries down to subsection + " \\expandafter\\listoftoc\\expandafter*\\expandafter{\\ext@subtoc}%" ;; show the toc without any heading + " \\end{minipage}\\par" + " \\bigskip\\noindent%" ;; add some vertical space after the toc and do not indent the following text + "}" + ("" "xpatch" nil) + "\\xapptocmd\\addtocentrydefault{%" ;; patch the KOMA-Script's generic toc entry generator + " \\ifusesectiontoc%" ;; if section toc entries should be generated + " \\expandafter\\tocbasic@addxcontentsline\\expandafter{\\ext@subtoc}{#1}{#2}{#3}%" ;; do it + " \\fi" + "}{}{}" + "\\xpretocmd\\section{\\usesectiontocfalse}{}{}%" ;; automatically switch of section toc entries at start of every \\section + "\\makeatother" +;;; - Appendix (main section unnumbered t and children unnumbered nil) + ("" "minitoc" nil) ;; to hide toc elements in maon toc but have them in a section toc and keep them in hyperref + ;; ("" "appendix" nil) + ;; "\\PassOptionsToPackage{hyphens}{url}" ;; line break of long urls (url package with [hyphens] option, will be loaded by hyperref) +;;; pdf imports !before tocstyle/tocbasic! + ("" "pdfpages" nil) + ("" "pdflscape" nil) +;;; Tikz + ("" "tikz" nil) + ("" "gnuplot-lua-tikz" nil) + ("" "pgfplots" nil) ;; ,pgfmath ;; for \\begin{axis} !needs by tikz (backgrounds) + "\\usepgflibrary{shapes.geometric}" + "\\usetikzlibrary{" + " arrows," ;; for arrow heads" + " calc," ;; % for manimulation of coordinates + " positioning," + " shapes.multipart," + ;; " %shadings," + " decorations.pathmorphing," + " backgrounds," ;; need package pgfplots + " pgfplotsclickable," ;; %after pgfplots, for /pgfplots/annot/js fillColor + " shadows," + " shadows.blur," + " mindmap," + "}" +;;; Other + ("" "xurl" nil) ;; line break of long urls + ("" "hyperref" nil) + ;; ("" "graphicx" t) + ;; ("" "grffile" t) + ;; ("" "wrapfig" nil) + ;; ("" "rotating" nil) + ;; ("normalem" "ulem" t) + ;; ("" "amsmath" t) + ;; ("" "textcomp" t) + ;; ("" "amssymb" t) + ;; ("" "capt-of" nil) + ) "See `org-latex-default-packages-alist'." :group 'my-org-export-article ;;:set 'org-set-packages-alist @@ -2005,32 +2032,58 @@ Text like <<...>>> will be replaced according to "Article closing." :group 'my-org-export-article) +(defcustom my-org-article-latex-draft + nil + "Article closing." + :group 'my-org-export-article) + ;;; Template -(defun my-org-article-latex-lang-template-value (property lang) - "Return lang version of property if in -`my-org-article-latex-lang-template-plist' defined, else use en as -default." - (let ((value (plist-get - my-org-article-latex-lang-template-plist - (intern (concat (symbol-name property) "-" lang))))) - (if value - value - (plist-get - my-org-article-latex-lang-template-plist - (intern (concat (symbol-name property) "-en")))))) +(defun my-org-article-latex-template-value (property &optional suffix) + "Return PROPERTY value defined in `my-org-article-latex-template-plist'. + +If SUFFIX is a string and not empty (e.g. \"de\") it is concat to +property with - (i.e. \"-de\") and returned if found otherwise +will return the -en version. + +Example: + (my-org-article-latex-template-value :documentclass-en) + \"english\" + (my-org-article-latex-template-value :documentclass \"de\") + \"ngerman\"" + (if suffix + ;; suffix (language) replacements + (let ((value (plist-get + my-org-article-latex-template-plist + (intern (concat (symbol-name property) "-" suffix))))) + (if value + value + (plist-get + my-org-article-latex-template-plist + (intern (concat (symbol-name property) "-en"))))) + ;; direct preplacements + (plist-get my-org-article-latex-template-plist property))) ;;;###autoload (defun my-org-article-latex-make-preamble (info &optional template snippet?) - "See `org-latex-make-preamble'" + "See `org-latex-make-preamble'. +Uses also `my-org-article-latex-template-value' with +`my-org-article-latex-template-plist' to inserts placeholders." (let* ((class (plist-get info :latex-class)) (lang (plist-get info :language)) (class-template (or template - (let* ((class-options - (string-replace - "<>" - (my-org-article-latex-lang-template-value :documentclass lang) + (let* (;; single replace + ;; (class-options + ;; (string-replace + ;; "<>" + ;; (my-org-article-latex-template-value :documentclass lang) + ;; (plist-get info :latex-class-options))) + ;; multi replace + (class-options + (s-replace-all + (list (cons "<>" + (my-org-article-latex-template-value :documentclass lang))) (plist-get info :latex-class-options))) (header (nth 1 (assoc class (plist-get info :latex-classes))))) (and (stringp header) @@ -2050,20 +2103,24 @@ default." snippet? (mapconcat #'org-element-normalize-string (list (s-replace-all - (list (cons "<>" - (my-org-article-latex-lang-template-value :babel lang)) + (list (if (plist-get info :draft) + (cons "<>" + (my-org-article-latex-template-value :draft)) + (cons "<>" "")) + (cons "<>" + (my-org-article-latex-template-value :babel lang)) (cons "<>" - (my-org-article-latex-lang-template-value :fontspec lang)) + (my-org-article-latex-template-value :fontspec lang)) (cons "<>" - (my-org-article-latex-lang-template-value :ruby lang)) + (my-org-article-latex-template-value :ruby lang)) (cons "<>" - (my-org-article-latex-lang-template-value :biblatex lang)) + (my-org-article-latex-template-value :biblatex lang)) (cons "<>" - (my-org-article-latex-lang-template-value :csquotes lang)) + (my-org-article-latex-template-value :csquotes lang)) (cons "<>" - (my-org-article-latex-lang-template-value :mtcselectlanguage lang)) + (my-org-article-latex-template-value :mtcselectlanguage lang)) (cons "<>" - (my-org-article-latex-lang-template-value :lstlistingname lang))) + (my-org-article-latex-template-value :lstlistingname lang))) (plist-get info :latex-header)) (and (not snippet?) (plist-get info :latex-header-extra))) diff --git a/settings/bibliography-settings.el b/settings/bibliography-settings.el index 8c8e8e03..36dcc54b 100644 --- a/settings/bibliography-settings.el +++ b/settings/bibliography-settings.el @@ -27,6 +27,7 @@ :load-path (lambda() (concat config-dir "lisp/citeproc")) :defer t) ;; used by org-ref +;; !in a org document run org-ref to test the installation (use-package org-ref ;; used with some preamble defs and \printbibliography (biblatex/biber, no html export), see also ox-bibtex :load-path (lambda() (concat config-dir "lisp/org-ref")) :after (org) @@ -35,7 +36,13 @@ ;; specify completion backends (defvar org-ref-completion-library 'org-ref-ivy-cite) ;; requires ivy-bibtex, must be set before requiring org-ref otherwise helm will be loaded :config - (setq bibtex-dialect 'biblatex)) ;; biblatex also for biber + ;; TODO: version 3 not working (with article-latex), the tex file still has the from cite:&... -> \cite{&...} + (setq org-ref-cite-insert-version 2) ;; org-ref-citation-links.el + (setq bibtex-dialect 'biblatex) ;; biblatex also for biber + (setq org-latex-prefer-user-labels t)) ;; reference to headings ref:section-name + +(use-package org-ref-ivy + :after (org-ref)) (use-package ox-bibtex ;; used with #+BIBLIOGRAPHY: ... (bibtex, with html export), see also org-ref :after (org) diff --git a/settings/org-settings.el b/settings/org-settings.el index 91db02cf..ec231c57 100644 --- a/settings/org-settings.el +++ b/settings/org-settings.el @@ -257,7 +257,7 @@ Example defines (setq org-startup-folded nil) ;; nil = showall = #+STARTUP: showall (setq org-startup-with-inline-images t) ;; #+STARTUP: inlineimages|noinlineimages, show inline images when loading a new Org file (setq org-use-sub-superscripts '{}) ;; braces are *required* in order to trigger interpretations as sub/superscript, see also `org-export-with-sub-superscripts'. C-c C-x \ (`org-toggle-pretty-entities') - (setq org-pretty-entities t) ;; see also `org-appear' and [C-c C-x \] (`org-toggle-pretty-entities') + (setq org-pretty-entities nil) ;; so much trouble in an article, see also `org-appear' and [C-c C-x \] (`org-toggle-pretty-entities') (setq org-pretty-entities-include-sub-superscripts t) ;; if `org-pretty-entities' is active include also sub-superscripts. (setq org-image-actual-width '(600)) ;; image width displayed in org (setq org-startup-with-latex-preview t) ;; #+STARTUP: latexpreview|nolatexpreview @@ -792,12 +792,13 @@ usage: #+HEADER: :prologue (mpl-prologue) ;; http://permalink.gmane.org/gmane.emacs.orgmode/93971 ;; https://emacs.stackexchange.com/questions/30575/adding-latex-newpage-before-a-heading/30892 - (defun my-org-headline-string-element (headline backend info) + (defun my-org-headline-string-element (headline backend info) "Return the org element representation of an element. Won't work on ~verb~/=code=-only headers" (let ((prop-point (next-property-change 0 headline))) (if prop-point (plist-get (text-properties-at prop-point headline) :parent)))) (defun my-org-latex-ensure-clearpage (headline backend info) - "Insert a clearpage before the heading if property clearpage is non-nil." + "Insert a clearpage before the heading if property clearpage is non-nil. +Uses function `my-org-headline-string-element'" (when (org-export-derived-backend-p backend 'latex) (let ((elmnt (my-org-headline-string-element headline backend info))) (when (and elmnt (org-element-property :CLEARPAGE elmnt)) @@ -909,78 +910,38 @@ usage: #+HEADER: :prologue (mpl-prologue) :config (setq org-latex-compiler "lualatex") ;; %latex in org-latex-pdf-process (setq org-latex-bib-compiler "biber") ;; %bib in org-latex-pdf-process - ;; pdflatex - ;; (setq org-latex-pdf-process - ;; '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f" - ;; "%bib %b" - ;; "%latex -shell-escape -interaction nonstopmode -output-directory %o %f" - ;; "%latex -shell-escape -interaction nonstopmode -output-directory %o %f")) (setq org-latex-pdf-process - '("lualatex --interaction=nonstopmode --output-directory=%o %f" - "biber %b" - "lualatex --interaction=nonstopmode --output-directory=%o %f" - "lualatex --interaction=nonstopmode --output-directory=%o %f")) + (if (executable-find "latexmk") + '("latexmk -f -pdf -%latex -interaction=nonstopmode -output-directory=%o %f") + (cond ((string-equal org-latex-compiler "lualatex") + '("lualatex --interaction=nonstopmode --output-directory=%o %f" + "biber %b" + "lualatex --interaction=nonstopmode --output-directory=%o %f" + "lualatex --interaction=nonstopmode --output-directory=%o %f")) + ((string-equal org-latex-compiler "pdflatex") + '("%latex -shell-escape -interaction nonstopmode -output-directory %o %f" + "%bib %b" + "%latex -shell-escape -interaction nonstopmode -output-directory %o %f" + "%latex -shell-escape -interaction nonstopmode -output-directory %o %f")) + (t '("%latex -interaction nonstopmode -output-directory %o %f" + "%latex -interaction nonstopmode -output-directory %o %f" + "%latex -interaction nonstopmode -output-directory %o %f"))))) (setq org-latex-listings t) (setq org-latex-listings-options '(("numbers" "left") ;; ("captionpos" "t") ;; not working, see org-latex-caption-above )) (setq org-latex-caption-above '(table src-block)) - (setq org-latex-hyperref-template " -%% DON't let hyperref overload the format of index and glossary. -%% I want to do that on my own in the stylefiles for makeindex... -\\makeatletter -\\let\\@old@wrindex=\\@wrindex -\\makeatother -\\hypersetup{%% - pdfauthor={%a}, - pdftitle={%t}, - pdfkeywords={%k}, - pdfsubject={%d}, - pdfcreator={%c}, - pdflang={%L}, - pdfproducer={LaTeX}, - %%pdfpagelabels, - %% Dokument an Fensterbreite anpassen, {XYZ null null 1} - pdfstartview=FitH, - %% Miniaturansicht nicht anzeigen - pdfpagemode=UseNone, - bookmarksopen=true, - bookmarksnumbered=true, - %% use true to enable colors below: - colorlinks=true, - linkcolor=black, - filecolor=darkblue, - menucolor=darkblue, - urlcolor=darkblue, - citecolor=black, - %% PDF link-darstellung, falls colorlinks=false. 0 0 0: nix. 0 0 1: default. - pdfborder=0 0 0, - %%frenchlinks=false, %% small caps instead of colors - %% false bei römisch und arabischen Zahlen - plainpages=false, - %% true bei römisch und arabischen Zahlen; Without hypertexnames it's just counting upwards; bei 4 -> iv - hypertexnames=true, -} -\\makeatletter -\\let\\@wrindex=\\@old@wrindex -\\makeatother -") - - (add-to-list 'org-latex-classes - '("koma-article" "\\documentclass{scrartcl}" - ("\\section{%s}" . "\\section*{%s}") - ("\\subsection{%s}" . "\\subsection*{%s}") - ("\\subsubsection{%s}" . "\\subsubsection*{%s}") - ("\\paragraph{%s}" . "\\paragraph*{%s}") - ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) (defun my-org-latex-export-to-pdf (&optional async subtreep visible-only body-only ext-plist) - "Like `org-latex-export-to-pdf' but with additional notification." + "Like `org-latex-export-to-pdf' but with additional notification. +And using the rewritten design for an article +`my-org-article-latex-export-to-pdf' (article-latex instead of +latex)." (interactive) (let ((outfile (org-export-output-file-name ".tex" subtreep))) - (org-export-to-file 'latex outfile + (org-export-to-file 'article-latex outfile async subtreep visible-only body-only ext-plist (lambda (file) ;; is called with FILE and has to return a file name. (let ((output (org-latex-compile file))) @@ -1002,6 +963,9 @@ usage: #+HEADER: :prologue (mpl-prologue) (my-org-latex-export-to-pdf async)) (defun my-org-export-pdf-async () + "For async a new emacs session starts using +`org-export-async-init-file'." + ;; TODO: define org-export-async-init-file (interactive) (my-org-export-pdf t))