Skip to content

Instantly share code, notes, and snippets.

@tmplt
Last active June 5, 2016 01:09
Show Gist options
  • Save tmplt/456d21f1e14da037645f to your computer and use it in GitHub Desktop.
Save tmplt/456d21f1e14da037645f to your computer and use it in GitHub Desktop.
Programming-fit Report Preamble

P^3 - Programming-fit Report Preamble

A decent report preamble, fit for programming-related topics. Big thanks to #latex on Freenode and various tex.stackexchange.com threads for the help.

How do I compile this?

Dependencies that aren't LaTeX packages:

For actual compilation, I highly recommend latexmk, which handles LaTeX packages.

"Holy smokes! This code is fugly, repetetive, and doesn't employ any code standards!"

Yeah.

% vim: set nospell
\documentclass[a4paper]{article}
% Some more actual space, LaTeX's default is rather small
\usepackage[margin = 0.75in]{geometry}
% T1 required by Linux Libertine
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[english]{babel}
\usepackage{setspace}
\usepackage{cleveref}
\usepackage{placeins}
\usepackage{url}
\usepackage[colorlinks = true,
urlcolor = blue,
citecolor = black,
linkcolor = black,
pdfauthor = {Author\ Name},
pdftitle = {placeholder\ title},
pdfsubject = {placeholder\ subject}]{hyperref}
% --------------- Glossary and glossary-related settings -------------- %
\usepackage[nopostdot, % No full-stop dot.
xindy,
nonumberlist, % No reference number in glossary
acronym, % For acronyms in a seperate list
toc, % Include in table of contents
section=subsubsection, % Make the glossaries a subsubsection
numberedsection % and give them numbers
]{glossaries}
\setglossarystyle{altlist} % Descriptions on a newline
\makeglossaries
\renewcommand*{\glstextformat}{\textbf}
% --------------- END -------------- %
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{lipsum}
% -------------------- Code snippets (with minted) -------------------- %
\usepackage{fontspec} % To select a new monospace font.
\setmonofont{Consolas} % Required ttf-vista-fonts
% Required for minted
\usepackage{keyval}
\usepackage{kvoptions}
\usepackage{fancyvrb}
\usepackage{float}
\usepackage{ifthen}
\usepackage{calc}
\usepackage{ifplatform}
\usepackage{pdftexcmds}
\usepackage{etoolbox}
\usepackage{xstring}
\usepackage{xcolor}
\usepackage{lineno}
\usepackage[cachedir={.minted}]{minted}
\setmintedinline{ %
fontsize=\scriptsize
}
\setminted[c++]{ %
linenos=true, % Line numbers
autogobble=true, % Automatically remove common whitespace
frame=lines,
framesep=2mm,
fontsize=\footnotesize
}
% Ugh
\let\icode\mintinline
\newcommand{\ic}{\icode{c++}}
\newcommand{\iterm}{\icode{bash}}
% Here be dragons
\makeatletter
\newenvironment{code}
{\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}{}%
\def\FV@BProcessLine##1{%
\hbox{%
\hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
\FancyVerbFormatLine{##1}%
}%
}%
\VerbatimEnvironment
\setbox\z@=\hbox\bgroup
\begin{minted}{c++}}
{\end{minted}\egroup
\leavevmode\vbox{\hrule\kern2mm\box\z@\kern2mm\hrule}}
\makeatother
\makeatletter
\newenvironment{term}
{\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}{}%
\def\FV@BProcessLine##1{%
\hbox{%
\hbox to\z@{\hss\theFancyVerbLine\kern\FV@NumberSep}%
\FancyVerbFormatLine{##1}%
}%
}%
\VerbatimEnvironment
\setbox\z@=\hbox\bgroup
\begin{minted}{bash}}
{\end{minted}\egroup
\leavevmode\vbox{\hrule\kern2mm\box\z@\kern2mm\hrule}}
\makeatother
\usepackage{nth}
% Placebo or not? No clue.
\usepackage{microtype}
\usepackage{graphicx}
\graphicspath{ {assets/} }
\usepackage{wrapfig}
% -------------------- Bib LaTeX -------------------- %
\usepackage{csquotes}
\usepackage[backend=biber,
sorting=nty,
style=authoryear,
dashed=false,
citestyle=apa]{biblatex}
\addbibresource{docs/ref.bib}
\let\cite\parencite
\usepackage{xpatch}
% Holy shit, more dragons!
%% These ones puts a period after authors in the bibliography
\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\revsdnamepunct}{}
\renewcommand*{\finalnamedelim}{\addcomma\space}
\xpretobibmacro{date+extrayear}{%
\setunit{\addperiod\space}%
}{}{}
% -------------------- -------------------- %
\usepackage[usestackEOL]{stackengine}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment