From 6df26c02303da93ae592b58c06e18adb646f47db Mon Sep 17 00:00:00 2001 From: Blendoit Date: Sat, 12 Sep 2020 12:34:41 -0700 Subject: Minted---colored source blocks in Org LaTeX exports. --- blendoit/.gitignore | 3 + blendoit/blendoit-init.org | 100 +++++++++++++++------------------- blendoit/blendoit-init.pdf | Bin 248467 -> 118502 bytes blendoit/secrets.org | 4 -- blendoit/test.el | 1 - blendoit/test.org | 7 --- init-custom.el | 13 +---- templates/documents/general.org | 10 ++-- templates/documents/general.org_title | 4 +- 9 files changed, 59 insertions(+), 83 deletions(-) delete mode 100644 blendoit/secrets.org delete mode 100644 blendoit/test.el delete mode 100644 blendoit/test.org diff --git a/blendoit/.gitignore b/blendoit/.gitignore index 0233e75..dff4699 100644 --- a/blendoit/.gitignore +++ b/blendoit/.gitignore @@ -1,2 +1,5 @@ # blendoit/.gitignore +_minted-blendoit-init/ +secrets.org +secrets.el \ No newline at end of file diff --git a/blendoit/blendoit-init.org b/blendoit/blendoit-init.org index 833a4ee..8422964 100644 --- a/blendoit/blendoit-init.org +++ b/blendoit/blendoit-init.org @@ -8,7 +8,7 @@ #+LATEX: \begin{abstract} GNU Emacs is most often used as a text editor. -The utmost level of customisation is afforded by enabling the user +The utmost level of customization is afforded by enabling the user to rewrite \textit{any} part of the source code and observe the editor's modified behaviour in real time. Since its inception in 1984, GNU Emacs has grown to be much more than a full-featured, high-productivity @@ -24,7 +24,7 @@ this is the endgame of \textit{literate programming}. * Introduction The following sections were laid out very deliberately. When we start Emacs, -Emacs Lisp source blocks contained in this document are evaluated +Emacs Lisp source code blocks contained in this document are evaluated sequentially---our editing environment is constructed in real time as we execute the blocks in order. For instance, we only begin loading packages once we ensured ~use-package~ is working properly. @@ -73,7 +73,7 @@ On my MS Windows machine, I add the path to Portable Git.[fn::Download from https://git-scm.com/download/win] #+BEGIN_SRC emacs-lisp -(if (string-equal system-type "windows-nt") + (when (string-equal system-type "windows-nt") (add-to-list 'exec-path "C:/Users/marius.peter/PortableGit/bin/")) #+END_SRC @@ -186,11 +186,16 @@ GNU/Linux. Frame transparency increases when focus is lost. ** Secrets -#+INCLUDE: ./secrets.org +The code contained in the =secrets.org= file is loaded by Emacs, but not +rendered in this PDF for the sake of privacy. It contains individually +identifying information such as names and e-mail addresses, which are used to +populate Org templates (Section [[~org-mode~]]). + +You need to create this =secrets.org= file, as it is ignored by =git= by +default. #+BEGIN_SRC emacs-lisp - (setq user-full-name "Marius Peter" - user-mail-address "blendoit@gmail.com") + (org-babel-load-file "~/.emacs.d/blendoit/secrets.org") #+END_SRC * Global key bindings @@ -385,62 +390,45 @@ format: *** LaTeX export -The following makes =TODO= items appear red and =CLOSED= items appear green in -Org's LaTeX exports. Very stylish, much flair! +We customize the format for org time stamps to make them pop in our exported +LaTeX documents. #+BEGIN_SRC emacs-lisp (setq org-latex-active-timestamp-format - "\\textcolor{SteelBlue}{\\texttt{%s}}") + "\\texttt{%s}") (setq org-latex-inactive-timestamp-format - "\\textcolor{ForestGreen}{\\texttt{%s}}") -#+END_SRC - -*** Publish - -In the following /alist/ (association list), we describe the projects publishable -via =org-publish=. We separate the publishing of =.org= files and attachments, -because an online tutorial recommended we do so. - -#+BEGIN_SRC emacs-lisp -(require 'ox-publish) -(setq org-publish-project-alist - '( - ("Safran-VIP-html" - :base-directory "~/org/WORK/Safran/programs/B787/VIP/doc/org/" - :base-extension "org" - :publishing-directory "~/org/WORK/Safran/programs/B787/VIP/doc/wiki/" - :recursive t - :publishing-function org-html-publish-to-html - :auto-preamble t - :auto-sitemap t - :sitemap-title "" ) - ("Safran-VIP-static" - :base-directory "~/org/WORK/Safran/programs/B787/VIP/doc/org/" - :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|mp4\\|ogg\\|swf" - :publishing-directory "~/org/WORK/Safran/programs/B787/VIP/doc/wiki/" - :recursive t - :publishing-function org-publish-attachment ) - ("Safran-VIP-all" - :components ("Safran-VIP-html" "Safran-VIP-static")) - ("Safran-MA700-html" - :base-directory "~/org/WORK/Safran/programs/MA700/doc/org/" - :base-extension "org" - :publishing-directory "~/org/WORK/Safran/programs/MA700/doc/wiki/" - :recursive t - :publishing-function org-html-publish-to-html - :auto-preamble t - :auto-sitemap t - :sitemap-title "" ) - ("Safran-MA700-static" - :base-directory "~/org/WORK/Safran/programs/MA700/doc/org/" - :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|mp4\\|ogg\\|swf" - :publishing-directory "~/org/WORK/Safran/programs/MA700/doc/wiki/" - :recursive t - :publishing-function org-publish-attachment ) - ("Safran-MA700-all" - :components ("Safran-MA700-html" "Safran-MA700-static")))) + "\\texttt{%s}") +#+END_SRC + +The following packages are loaded for every LaTeX export + +#+BEGIN_SRC emacs-lisp + (setq org-latex-packages-alist + '(("AUTO" "polyglossia" t + ("xelatex" "lualatex")) + ("AUTO" "babel" t + ("pdflatex")) + ("AUTO" "booktabs" t + ("pdflatex")) + ("table,svgnames" "xcolor" t + ("pdflatex")))) #+END_SRC +Little bonus for GNU/Linux users: syntax highlighting for source code blocks in +LaTeX exports. + +#+BEGIN_SRC emacs-lisp + (when (string-equal system-type "gnu/linux") + (add-to-list 'org-latex-packages-alist '("AUTO" "minted" t + ("pdflatex" "lualatex"))) + (setq org-latex-listings 'minted) + (setq org-latex-minted-options + '(("style" "friendly") ()))) +#+END_SRC + +The following makes =TODO= items appear red and =CLOSED= items appear green in +Org's LaTeX exports. Very stylish, much flair! + *** Export This creates a shorter binding for the most common Org export: Org \rightarrow diff --git a/blendoit/blendoit-init.pdf b/blendoit/blendoit-init.pdf index bd0f983..1f28bb5 100644 Binary files a/blendoit/blendoit-init.pdf and b/blendoit/blendoit-init.pdf differ diff --git a/blendoit/secrets.org b/blendoit/secrets.org deleted file mode 100644 index a6ca895..0000000 --- a/blendoit/secrets.org +++ /dev/null @@ -1,4 +0,0 @@ -#+BEGIN_SRC emacs-lisp - (setq user-full-name "Marius Peter" - user-mail-address "blendoit@gmail.com") -#+END_SRC diff --git a/blendoit/test.el b/blendoit/test.el deleted file mode 100644 index ca95879..0000000 --- a/blendoit/test.el +++ /dev/null @@ -1 +0,0 @@ -(when window-system (add-hook 'prog-mode-hook 'hl-line-mode)) diff --git a/blendoit/test.org b/blendoit/test.org deleted file mode 100644 index d4492b8..0000000 --- a/blendoit/test.org +++ /dev/null @@ -1,7 +0,0 @@ -** hl-line - -Highlight line at point. - -#+BEGIN_SRC emacs-lisp -(when window-system (add-hook 'prog-mode-hook 'hl-line-mode)) -#+END_SRC diff --git a/init-custom.el b/init-custom.el index b7f6584..3574a4e 100644 --- a/init-custom.el +++ b/init-custom.el @@ -79,17 +79,10 @@ ("\\section{%s}" . "\\section*{%s}") ("\\subsection*{%s}" . "\\subsection*{%s}") ("\\subsubsection*{%s}" . "\\subsubsection*{%s}")))) - '(org-latex-packages-alist - '(("AUTO" "polyglossia" t - ("xelatex" "lualatex")) - ("AUTO" "babel" t - ("pdflatex")) - ("AUTO" "booktabs" t - ("pdflatex")) - ("table,svgnames" "xcolor" t - ("pdflatex")))) + '(org-latex-logfiles-extensions + '("aux" "bcf" "blg" "fdb_latexmk" "fls" "figlist" "idx" "log" "nav" "out" "ptc" "run.xml" "snm" "toc" "vrb" "xdv")) '(org-latex-pdf-process - '("latexmk -pdf -f -interaction=nonstopmode -pdflatex=\"%latex\" -outdir=%o %f")) + '("latexmk -pdf -f -interaction=nonstopmode -shell-escape -pdflatex=\"lualatex\" -outdir=%o %f")) '(org-latex-toc-command "\\tableofcontents\\clearpage") '(org-log-done 'time) '(org-startup-align-all-tables t) diff --git a/templates/documents/general.org b/templates/documents/general.org index 43bf396..8b360db 100644 --- a/templates/documents/general.org +++ b/templates/documents/general.org @@ -1,4 +1,4 @@ -# -*- mode: org; -*- +# -*- mode: org; -*- # # Hide Org mode tags #+OPTIONS: tags:nil @@ -7,8 +7,10 @@ # Ensure room for header and footer #+LATEX_HEADER: \usepackage[left=1in,right=1in,top=1in,bottom=1.75in]{geometry} -# A beautiful font indeed -#+LATEX_HEADER: \usepackage{fourier} +# Beautiful fonts ONLY +#+LATEX_HEADER: \usepackage{fontspec} +#+LATEX_HEADER: \setmainfont{liberation serif} +#+LATEX_HEADER: \setmonofont{hermit} # Get total page count to insert in footer #+LATEX_HEADER: \usepackage{lastpage} @@ -26,7 +28,7 @@ #+LATEX_HEADER: \usepackage{fancyhdr} #+LATEX_HEADER: \setlength{\headheight}{40pt} #+LATEX_HEADER_EXTRA: \pagestyle{fancy} -#+LATEX_HEADER_EXTRA: \fancyhead[L]{\rule[-12pt]{0pt}{0pt}\theauthor} +#+LATEX_HEADER_EXTRA: \fancyhead[L]{\rule[-12pt]{0pt}{0pt}\texttt{\theauthor}} #+LATEX_HEADER_EXTRA: \fancyhead[C]{\large\textbf{\thetitle}} #+LATEX_HEADER_EXTRA: \fancyhead[R]{\thedate} #+LATEX_HEADER_EXTRA: \renewcommand{\headrulewidth}{1.4pt} diff --git a/templates/documents/general.org_title b/templates/documents/general.org_title index 3cf4431..c2c3c09 100644 --- a/templates/documents/general.org_title +++ b/templates/documents/general.org_title @@ -1,8 +1,10 @@ +# -*- mode: org; -*- # + #+OPTIONS: title:nil toc:nil # Increase spacing between header rule and main text body #+LATEX: \rule[-2in]{0pt}{0pt}\\ #+LATEX: \Huge\textbf{\thetitle}\\[1in] -#+LATEX: \LARGE\theauthor\\ +#+LATEX: \LARGE\texttt{\theauthor}\\ #+LATEX: \thedate #+LATEX: \clearpage -- cgit v1.2.3