emacs.d/etc/yasnippet/snippets/org-mode/latex-header-block
2022-08-21 17:58:08 +02:00

106 lines
3.8 KiB
Plaintext

# -*- coding: utf-8 -*-
# name: latex-header-block
# key: lhb
# expand-env: ((yas-indent-line 'fixed))
# --
#+begin_src latex :noweb yes :results raw
,#+latex_header: <<${1:latex}-header>>
#+end_src
#+name: $1-header
#+begin_src latex :exports none
% LaTeX PREAMBLE:
% See: https://list.orgmode.org/87o807r7fr.fsf@posteo.net/
% From: "Juan Manuel Macías" <maciaschain@posteo.net>
% To: orgmode <emacs-orgmode@gnu.org>
% Subject: [tip] Insert arbitrary LaTeX code at the beginning of any float environment
% Date: Sun, 08 May 2022 22:22:16 +0000
% Message-ID: <87o807r7fr.fsf@posteo.net>
% LANGUAGE:
\usepackage{babel}
\usepackage{fvextra}
\usepackage{csquotes}
% LISTS:
\usepackage{enumitem}
\setlist{noitemsep}
% CAPTIONS, LISTINGS, and SUBCAPTIONS
% 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.
% Use the "DejaVu Sans Mono" as typewriter font for engrave-faces listings.
\usepackage{caption}
\captionsetup[listing]{position=below,skip=0em}
\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase]
\usepackage{subcaption}
% TABLES:
% https://tex.stackexchange.com/a/341254 answers:
% "How differ the environments tabular, tabular*, and tabularx?"
% https://emacs.stackexchange.com/a/28903 answers:
% "How to tweak org-mode table colors for latex export only?"
% https://tex.stackexchange.com/a/468596 answers:
% "How to format LaTeX using siunitx?"
% https://tex.stackexchange.com/a/355396 answers:
% "How to load colortbl and xcolor for maximal interoperability?"
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{tabularx} % DANGER: beware of Org table :width and :align options!
% STANDALONE FIGURES AND TABLES:
% https://xuc.me/blog/reuse-tikz-figures-in-articles-and-slides/ explains that
% making fake beamer commands for standalone pictures is less error-prone than
% using beamerarticle.
\usepackage{standalone}
\usepackage{xparse}
\NewDocumentCommand{\onslide}{s t+ d<>}{}
\NewDocumentCommand{\only}{d<>}{}
\NewDocumentCommand{\uncover}{d<>}{}
\NewDocumentCommand{\visible}{d<>}{}
\NewDocumentCommand{\invisible}{d<>}{}
% PAGE LAYOUT:
\usepackage[headheight=20mm,top=40mm,bottom=20mm,left=0.1\paperwidth,right=0.1\paperwidth,heightrounded,verbose]{geometry}
% SI UNITS:
\usepackage[load-configurations=abbreviations]{siunitx}
\sisetup{
range-phrase = \ensuremath{\text{\,\textendash\,}},
range-units = brackets,
separate-uncertainty,
}
\DeclareSIUnit\dollar{\$}
\DeclareSIUnit\euro{€}
\DeclareSIUnit\mK{\milli\kelvin}
\DeclareSIUnit\mbar{\milli\bar}
\DeclareSIUnit\micron{\micro\meter}
\DeclareSIUnit\nW{\nano\watt}
% TIKZ AND PGFPLOTS:
\usepackage{tikz}
\usetikzlibrary{3d,arrows,backgrounds,calc,plotmarks}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\def\axisdefaultwidth{90mm}
\def\axisdefaultheight{75mm}
% SYMBOLS FOR FLUID MECHANICS
\newcommand{\Knudsen}{\mbox{\textit{Kn}}}
\newcommand{\Nusselt}{\mbox{\textit{Nu}}}
\newcommand{\Reynolds}{\mbox{\textit{Re}}}
% FLOAT BARRIERS:
% https://tex.stackexchange.com/a/118667 answers:
% "How to make float barriers for subsections as placeins does for sections?"
% 1. Make section an implicit float barrier:
\usepackage[section]{placeins}
% 2. Make subsection an implicit float barrier:
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsection\expandafter{%
\expandafter\@fb@secFB\subsection
}%
}
\makeatother
% 3. Make subsubsection an implicit float barrier:
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsubsection\expandafter{%
\expandafter\@fb@secFB\subsubsection
}%
}
\makeatother
#+end_src