Move all LaTeX preamble tweaks to setup-include.org

This commit is contained in:
Gerard Vermeulen 2021-12-29 10:05:43 +01:00
parent bd11afdcf7
commit b5f8ed46cc
3 changed files with 150 additions and 118 deletions

2
.gitignore vendored
View File

@ -19,7 +19,7 @@
latexmkrc
org-store-link
setupfile.org
setup-include.org
/_minted-README
/eln-cache

View File

@ -2,113 +2,8 @@
#+author: Gerard Vermeulen
#+latex_class: article
#+latex_class_options: [11pt,a4paper,english,svgnames,tables]
#+setupfile: setupfile.org
* LaTeX headers :noexport:
#+begin_src latex-header
% LANGUAGE:
\usepackage{babel}
\usepackage{fvextra}
\usepackage{csquotes}
% LISTS:
\usepackage{enumitem}
\setlist{noitemsep}
% TECHNICS:
\usepackage{siunitx}
\usepackage{tikz}
% LISTINGS:
% Section 2.6 of caption-eng.pdf (texdoc caption) explains that the sign
% of "skip" depends on the assumption "position=above" or "position=below".
% The assumption should match the real caption position in the LaTeX code.
\usepackage{caption}
\usepackage[newfloat]{minted}
\captionsetup[listing]{position=below,skip=0em}
\usemintedstyle{xcode}
% TABLES:
% https://tex.stackexchange.com/questions/341205/
% what-is-the-difference-between-tabular-tabular-and-tabularx-environments
% https://emacs.stackexchange.com/questions/26179/
% change-org-mode-table-style-just-for-latex-export
% https://tex.stackexchange.com/questions/468585/
% table-formatting-using-siunitx
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{tabularx} % DANGER: beware of Org table :width and :align options!
% FANCY HEADERS:
\usepackage{fancyhdr}
\usepackage{lastpage}
% PAGE GEOMETRY:
\usepackage[
headheight=20mm,
top=40mm,
bottom=20mm,
left=60pt,
right=60pt,
heightrounded,
verbose,
]{geometry}
#+end_src
#+begin_src latex-header
% FLOAT BARRIERS:
% https://tex.stackexchange.com/questions/118662/use-placeins-for-subsections
% Make section an implicit float barrier:
\usepackage[section]{placeins}
% Make subsection an implicit float barrier:
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsection\expandafter{%
\expandafter\@fb@secFB\subsection
}%
}
\makeatother
% Make subsubsection an implicit float barrier:
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsubsection\expandafter{%
\expandafter\@fb@secFB\subsubsection
}%
}
\makeatother
#+end_src
#+begin_src latex-header
% Add fancy headers and footers to normal pages.
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[C]{\emph{
Emacs setup for use with \LaTeX{}, Org, and Python -- Gerard Vermeulen}}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhead[L]{\includegraphics[height=1.8cm]{Org-mode-unicorn.png}}
\fancyhead[C]{
Page: \thepage/\pageref{LastPage} \\
\text{ } \\
\text{ } \\
DRAFT
}
\fancyhead[R]{\includegraphics[height=1.8cm]{Emacs-logo.png}}
% Add fancy header and footer to custom titlepage.
% https://tex.stackexchange.com/questions/506102/
% adding-header-and-footer-to-custom-titlepage
\fancypagestyle{titlepage}{%
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[C]{\emph{
Emacs setup for use with \LaTeX{}, Org, and Python -- Gerard Vermeulen}}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhead[L]{\includegraphics[height=1.8cm]{Org-mode-unicorn.png}}
\fancyhead[C]{
\pageref{LastPage} pages \\
\text{ } \\
\text{ } \\
DRAFT
}
\fancyhead[R]{\includegraphics[height=1.8cm]{Emacs-logo.png}}
}
#+end_src
#+setupfile: "setup-include.org"
#+include: "setup-include.org"
* Quick start
:PROPERTIES:
@ -1066,7 +961,7 @@ The code in listing [[lst:customize-org-babel]], [[lst:customize-org]], and
(cperl "perl")
(shell-script "bash")
(caml "ocaml")
(org "text")))
(Org "latex")))
'(org-latex-minted-options '(("bgcolor" "LightGoldenrodYellow")))
`(org-latex-logfiles-extensions
',(cl-union '("lof" "lot") org-latex-logfiles-extensions :test #'equal))
@ -1378,7 +1273,7 @@ this broken function (broken, since it relies on support only in org-mode before
#+caption[Define =my-ox-latex-export-buffer-local-variables=]:
#+caption: Define =my-ox-latex-export-buffer-local-variables=.
#+name: lst:emacs-lisp-setup-defun
#+begin_src emacs-lisp
#+begin_src emacs-lisp :results silent
(defun my-ox-latex-export-buffer-local-variables (title-page)
(with-eval-after-load 'ox
(make-variable-buffer-local 'org-export-before-parsing-hook)
@ -1451,19 +1346,156 @@ Listing [[lst:emacs-lisp-setup-call]] initializes the buffer local variables
\end{titlepage}
#+end_src
*** [[info:org#Export Settings][SETUPFILE export keyword usage]]
*** [[info:org#Export Settings][#+SETUPFILE: and #+INCLUDE: usage]]
:PROPERTIES:
:CUSTOM_ID: sec:setupfile-export-keyword-usage
:CUSTOM_ID: sec:setupfile+include-usage
:END:
#+caption[Setup file export keyword settings]:
#+caption: Setup file export keyword settings.
#+name: lst:setup-file-export-keyword-settings
#+begin_src org :tangle setupfile.org
#+babel: :cache no
#+macro: kbd @@html:<kbd>$1</kbd>@@@@latex:\colorbox{PowderBlue}{\texttt{$1}}@@
#+property: header-args:emacs-lisp :exports code :results silent :tangle init.el
#+startup: content
#+begin_src org
,#+babel: :cache no
,#+macro: kbd @@html:<kbd>$1</kbd>@@@@latex:\colorbox{PowderBlue}{\texttt{$1}}@@
,#+property: header-args:emacs-lisp :exports code :results silent :tangle init.el
,#+property: header-args:org :tangle setup-include.org
,#+startup: content
#+end_src
#+caption[LaTeX preamble: language, lists and floats]:
#+caption: LaTeX preamble: language, lists and floats.
#+name: lst:use-latex-header-1
#+begin_src org
,#+begin_src latex-header
% LANGUAGE:
\usepackage{babel}
\usepackage{fvextra}
\usepackage{csquotes}
% LISTS:
\usepackage{enumitem}
\setlist{noitemsep}
% LISTINGS:
% Section 2.6 of caption-eng.pdf (texdoc caption) explains that the sign
% of "skip" depends on the assumption "position=above" or "position=below".
% The assumption should match the real caption position in the LaTeX code.
\usepackage{caption}
\usepackage[newfloat]{minted}
\captionsetup[listing]{position=below,skip=0em}
\usemintedstyle{xcode}
% TABLES:
% https://tex.stackexchange.com/questions/341205/
% what-is-the-difference-between-tabular-tabular-and-tabularx-environments
% https://emacs.stackexchange.com/questions/26179/
% change-org-mode-table-style-just-for-latex-export
% https://tex.stackexchange.com/questions/468585/
% table-formatting-using-siunitx
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{tabularx} % DANGER: beware of Org table :width and :align options!
,#+end_src
#+end_src
#+caption[LaTeX preamble: page layout]:
#+caption: LaTeX preamble: page layout.
#+name: lst:use-latex-header-2
#+begin_src org
,#+begin_src latex-header
% PAGE LAYOUT:
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[
headheight=20mm,
top=40mm,
bottom=20mm,
left=60pt,
right=60pt,
heightrounded,
verbose,
]{geometry}
% TECHNICS:
\usepackage{siunitx}
\usepackage{tikz}
,#+end_src
#+end_src
#+caption[LaTeX preamble: float barriers]:
#+caption: LaTeX preamble: float barriers.
#+name: lst:use-latex-header-3
#+begin_src org
,#+begin_src latex-header
% FLOAT BARRIERS:
% https://tex.stackexchange.com/questions/118662/use-placeins-for-subsections
% Make section an implicit float barrier:
\usepackage[section]{placeins}
% Make subsection an implicit float barrier:
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsection\expandafter{%
\expandafter\@fb@secFB\subsection
}%
}
\makeatother
% Make subsubsection an implicit float barrier:
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsubsection\expandafter{%
\expandafter\@fb@secFB\subsubsection
}%
}
\makeatother
,#+end_src
#+end_src
#+caption[LaTeX preamble: fancy headers and footers]:
#+caption: LaTeX preamble: fancy headers and footers.
#+name: lst:use-latex-header-4
#+begin_src org
,#+begin_src latex-header
% FANCY HEADERS AND FOOTERS:
% Add fancy headers and footers to normal pages.
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[C]{\emph{
Emacs setup for use with \LaTeX{}, Org, and Python -- Gerard Vermeulen}}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhead[L]{\includegraphics[height=1.8cm]{Org-mode-unicorn.png}}
\fancyhead[C]{
Page: \thepage/\pageref{LastPage} \\
\text{ } \\
\text{ } \\
DRAFT
}
\fancyhead[R]{\includegraphics[height=1.8cm]{Emacs-logo.png}}
% Add fancy header and footer to custom titlepage.
% https://tex.stackexchange.com/questions/506102/
% adding-header-and-footer-to-custom-titlepage
\fancypagestyle{titlepage}{%
\fancyhf{}
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[C]{\emph{
Emacs setup for use with \LaTeX{}, Org, and Python -- Gerard Vermeulen}}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhead[L]{\includegraphics[height=1.8cm]{Org-mode-unicorn.png}}
\fancyhead[C]{
\pageref{LastPage} pages \\
\text{ } \\
\text{ } \\
DRAFT
}
\fancyhead[R]{\includegraphics[height=1.8cm]{Emacs-logo.png}}
}
% #+latex_header: END.
,#+end_src
#+end_src
* Editing

View File

@ -24,7 +24,7 @@ emacs -Q --batch --eval "
(setq python-indent-guess-indent-offset nil)
(org-babel-tangle-file \"$1\" \"init.el\" \"emacs-lisp\")
(org-babel-tangle-file \"$1\" \"setupfile.org\" \"org\"))
(org-babel-tangle-file \"$1\" \"setup-include.org\" \"org\"))
"
# Local Variables: