feat: add latex template

This commit is contained in:
Leon Schwarzäugl 2024-12-31 21:31:53 +01:00
parent 526b9acead
commit 68bc6f5473
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
18 changed files with 924 additions and 42 deletions

View file

@ -488,6 +488,7 @@ This file defines the templates that are being exposed by the flake. These can b
"rust" "rust"
"go" "go"
"cpp" "cpp"
"latex"
"default" "default"
]; ];
in in
@ -13006,6 +13007,7 @@ This provides several utilities for LaTeX in Emacs, including many completions a
(setq TeX-auto-save t) (setq TeX-auto-save t)
(setq TeX-save-query nil) (setq TeX-save-query nil)
(setq TeX-parse-self t) (setq TeX-parse-self t)
(setq-default TeX-engine 'luatex)
(setq-default TeX-master nil) (setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode) (add-hook 'LaTeX-mode-hook 'visual-line-mode)

View file

@ -924,6 +924,7 @@ create a new one."
(setq TeX-auto-save t) (setq TeX-auto-save t)
(setq TeX-save-query nil) (setq TeX-save-query nil)
(setq TeX-parse-self t) (setq TeX-parse-self t)
(setq-default TeX-engine 'luatex)
(setq-default TeX-master nil) (setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode) (add-hook 'LaTeX-mode-hook 'visual-line-mode)

View file

@ -5,6 +5,7 @@ let
"rust" "rust"
"go" "go"
"cpp" "cpp"
"latex"
"default" "default"
]; ];
in in

1
templates/latex/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

292
templates/latex/.gitignore vendored Normal file
View file

@ -0,0 +1,292 @@
# nix build output
result
## PDF output (but not in figures/)
*.pdf
!figures/*.pdf
!figures/**/*.pdf
## Core latex/pdflatex auxiliary files:
*.aux
*.lof
*.log
*.lot
*.fls
*.out
*.toc
*.fmt
*.fot
*.cb
*.cb2
.*.lb
## Intermediate documents:
*.dvi
*.xdv
*-converted-to.*
# these rules might exclude image files for figures etc.
# *.ps
# *.eps
# *.pdf
## Generated if empty string is given at "Please type another file name for output:"
.pdf
## Bibliography auxiliary files (bibtex/biblatex/biber):
*.bbl
*.bcf
*.blg
*-blx.aux
*-blx.bib
*.run.xml
## Build tool auxiliary files:
*.fdb_latexmk
*.synctex
*.synctex(busy)
*.synctex.gz
*.synctex.gz(busy)
*.pdfsync
## Build tool directories for auxiliary files
# latexrun
latex.out/
## Auxiliary and intermediate files from other packages:
# algorithms
*.alg
*.loa
# achemso
acs-*.bib
# amsthm
*.thm
# beamer
*.nav
*.pre
*.snm
*.vrb
# changes
*.soc
# comment
*.cut
# cprotect
*.cpt
# elsarticle (documentclass of Elsevier journals)
*.spl
# endnotes
*.ent
# fixme
*.lox
# feynmf/feynmp
*.mf
*.mp
*.t[1-9]
*.t[1-9][0-9]
*.tfm
#(r)(e)ledmac/(r)(e)ledpar
*.end
*.?end
*.[1-9]
*.[1-9][0-9]
*.[1-9][0-9][0-9]
*.[1-9]R
*.[1-9][0-9]R
*.[1-9][0-9][0-9]R
*.eledsec[1-9]
*.eledsec[1-9]R
*.eledsec[1-9][0-9]
*.eledsec[1-9][0-9]R
*.eledsec[1-9][0-9][0-9]
*.eledsec[1-9][0-9][0-9]R
# glossaries
*.acn
*.acr
*.glg
*.glo
*.gls
*.glsdefs
*.lzo
*.lzs
# uncomment this for glossaries-extra (will ignore makeindex's style files!)
# *.ist
# gnuplottex
*-gnuplottex-*
# gregoriotex
*.gaux
*.gtex
# htlatex
*.4ct
*.4tc
*.idv
*.lg
*.trc
*.xref
# hyperref
*.brf
# knitr
*-concordance.tex
# TODO Uncomment the next line if you use knitr and want to ignore its generated tikz files
# *.tikz
*-tikzDictionary
# listings
*.lol
# luatexja-ruby
*.ltjruby
# makeidx
*.idx
*.ilg
*.ind
# minitoc
*.maf
*.mlf
*.mlt
*.mtc[0-9]*
*.slf[0-9]*
*.slt[0-9]*
*.stc[0-9]*
# minted
_minted*
*.pyg
# morewrites
*.mw
# nomencl
*.nlg
*.nlo
*.nls
# pax
*.pax
# pdfpcnotes
*.pdfpc
# sagetex
*.sagetex.sage
*.sagetex.py
*.sagetex.scmd
# scrwfile
*.wrt
# sympy
*.sout
*.sympy
sympy-plots-for-*.tex/
# pdfcomment
*.upa
*.upb
# pythontex
*.pytxcode
pythontex-files-*/
# tcolorbox
*.listing
# thmtools
*.loe
# TikZ & PGF
*.dpth
*.md5
*.auxlock
# todonotes
*.tdo
# vhistory
*.hst
*.ver
# easy-todo
*.lod
# xcolor
*.xcp
# xmpincl
*.xmpi
# xindy
*.xdy
# xypic precompiled matrices and outlines
*.xyc
*.xyd
# endfloat
*.ttt
*.fff
# Latexian
TSWLatexianTemp*
## Editors:
# WinEdt
*.bak
*.sav
# Texpad
.texpadtmp
# LyX
*.lyx~
# Kile
*.backup
# gummi
.*.swp
# KBibTeX
*~[0-9]*
# TeXnicCenter
*.tps
# auto folder when using emacs and auctex
./auto/*
*.el
# expex forward references with \gathertags
*-tags.tex
# standalone packages
*.sta
# Makeindex log files
*.lpz
# xwatermark package
*.xwm
# REVTeX puts footnotes in the bibliography by default, unless the nofootinbib
# option is specified. Footnotes are the stored in a file with suffix Notes.bib.
# Uncomment the next line to have this generated file ignored.
#*Notes.bib

View file

@ -0,0 +1,3 @@
$pdf_mode = 4;
@default_files = ('000-main.tex');
$lualatex = "lualatex %O -shell-escape %S";

View file

@ -0,0 +1,75 @@
%! TEX root = **/000-main.tex
% vim: spell spelllang=en:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PREAMBLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{001-preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXTRA PACKAGES / CONFIG
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% METADATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% remove when using \maketitle:
\renewcommand\and{\\[\baselineskip]}
\title{My title \\ \Large \normalfont My Subtitle}
\author{First Author \and Second Author}
\date{\today}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TITLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Default title or use titlepage.tex
%\maketitle
\include{005-titlepage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TOC & lists
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{Roman}
%\setcounter{tocdepth}{2}
\tableofcontents \pagebreak
\listoffigures \pagebreak
\listoftables \clearpage
\pagenumbering{arabic}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SECTIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Paragraph spacing (placed after ToC)
\setlength{\parskip}{1em plus 0.5em minus 0.2em}
%\setlength{\parindent}{0pt}
\include{010-introduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BIBLIO
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\printbibliography[heading=bibintoc]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% APPENDIX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% uncomment to add appendix section prefix to numbering
%\appendixpagenumbering
\appendix
\include{990-appendix}
\end{document}

View file

@ -0,0 +1,204 @@
%! TEX root = **/000-main.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LaTeX preamble, load in main.tex with: \input{preamble}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt, oneside]{article}
\usepackage[a4paper, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
% for debugging overfulls
%\documentclass[draft, 12pt, oneside]{article}
%\usepackage[showframe, a4paper, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FONTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{microtype}
\setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LANGUAGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguages{spanish,catalan}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% BIBLIOGRAPHY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[
backend=biber,
style=numeric,
]{biblatex}
\DeclareNameAlias{default}{family-given}
\addbibresource{biblio.bib}
\usepackage{fvextra} % Req by minted (must load before csquotes)
\usepackage{csquotes} % For bibliography quotations
\DeclareQuoteAlias{spanish}{catalan}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% COMMON
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{color, xcolor} % more colors
\usepackage{graphicx} % graphics
\graphicspath{{./figures/}}
\usepackage{comment}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MATHS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{mathtools} % amsmath + more
\usepackage{amsthm} % Theorem enviroment
\usepackage{amssymb} % More symbols
\usepackage{amstext} % Text inside mathenv
%\usepackage{relsize} % Bigger math with mathlarger{___}
%\usepackage{nicefrac} % nice fractions in one line
%\usepackage{IEEEtrantools} % Complex equation arrays
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% REFERENCES (load order is important)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{varioref} % reference far away (1)
\usepackage[colorlinks = true]{hyperref} % links in references (2)
\usepackage{cleveref} % smart references (3)
%hyperref configuration so that it doesn't contrast so much colorlinks,
\hypersetup{
linkcolor={black},
citecolor={black},
%linkcolor={red!50!black},
%citecolor={blue!50!black},
urlcolor={blue!80!black}
}
\usepackage[bottom]{footmisc} % Footnotes at bottom of page
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FIGURES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage[export]{adjustbox} % Adjust table size
\usepackage{float} % Force tables and images position (H and H!)
%\usepackage{wrapfig} % Wrap images like in HTML
\usepackage[justification=centering]{caption}
%\usepackage{subcaption} % Subfigures
%\usepackage[framemethod=tikz]{mdframed} % Custom frames
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TABLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage{colortbl, booktabs} % Better tables
%\usepackage{tabularx}
%\usepackage{longtable} % Multiple page table (does not work with tabularx)
\usepackage{xltabular, colortbl, booktabs} % longtable + tabularx (has bug with booktabs: fix below)
% Split cell in lines and more formating options inside table
\usepackage{array, multirow, multicol, makecell}
%%%
% bug fix for booktabs + xltabular incompatibility
\makeatletter
\def\@BTrule[#1]{%
\ifx\longtable\undefined
\let\@BTswitch\@BTnormal
\else\ifx\hline\LT@hline
\nobreak
\let\@BTswitch\@BLTrule
\else
\let\@BTswitch\@BTnormal
\fi\fi
\global\@thisrulewidth=#1\relax
\ifnum\@thisruleclass=\tw@\vskip\@aboverulesep\else
\ifnum\@lastruleclass=\z@\vskip\@aboverulesep\else
\ifnum\@lastruleclass=\@ne\vskip\doublerulesep\fi\fi\fi
\@BTswitch}
\makeatother
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SIUNITX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage[alsoload=hep]{siunitx} % SI units and uncertainties
%\sisetup{locale = FR} % Commas and so on for spanish
%\sisetup{separate-uncertainty=true}
%\sisetup{
%per-mode=fraction,
%fraction-function=\nicefrac
%}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TIKZ
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage{tikz}
%\usetikzlibrary{arrows}
%\usetikzlibrary{scopes}
%\usetikzlibrary{babel}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MINTED
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{minted}
\definecolor{codeBg}{HTML}{FFFDE7}
\setminted{
%style=pastie,
frame=lines,
framesep=3mm,
linenos,
breaklines=true,
encoding=utf8,
fontsize=\footnotesize,
bgcolor=codeBg
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CUSTOM COMMANDS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% empty whitepage without numbering
\newcommand{\whitepage}{
\clearpage\thispagestyle{empty}\addtocounter{page}{-1} \newpage \clearpage
}
% Add command before appendix section for page numbering: A-1
\newcommand{\appendixpagenumbering}{
\break
\pagenumbering{arabic}
\renewcommand{\thepage}{\thesection-\arabic{page}}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CUSTOM MATH OPERATORS (functions not in italic in math mode)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\DeclareMathOperator{\arcsec}{arcsec}
%\DeclareMathOperator{\arccot}{arccot}
%\DeclareMathOperator{\arccsc}{arccsc}
%\DeclareMathOperator{\cis}{cis}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% MISC
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usepackage{datetime} % Customize date
%% \monthyeardate\today gives the date without the day
%\newdateformat{monthyeardate}{%
%\monthname[\THEMONTH], \THEYEAR}

View file

@ -0,0 +1,28 @@
%! TEX root = **/000-main.tex
% vim: spell spelllang=en:
\thispagestyle{empty}
\clearpage
\setcounter{page}{-1}
\makeatletter
\begin{titlepage}
{
\centering
\includegraphics[width=0.9\textwidth]{institution-logo}
\null%
\vspace{3em}
{\Huge \bfseries \@title \par}
\vspace{2em}
{\large \scshape \@date \par}
\vfill
\begin{center}
% Supplementary image
\end{center}
\vspace{5em}
\vfill
{\raggedleft \large \@author \par}
}
\end{titlepage}
\makeatother

View file

@ -0,0 +1,39 @@
%! TEX root = **/000-main.tex
% vim: spell spelllang=en:
\section{Introduction}%
\label{sec:introduction}
\(E = mc^2\) \cite{einstein}
\begin{figure}[H]
\centering
\includegraphics[width=0.3\linewidth]{Professortocat_v2}
\caption{Professor OctoCat}%
\label{fig:profocto}
\end{figure}
As we can see in \cref{fig:profocto}, the professor is holding an apple.
\begin{table}[H]
\begin{center}
\caption{Table captions go on top of the tables}%
\label{tab:example}
\begin{tabular}{ccc}
\toprule
a & b & c \\
\midrule
0 & 2 & 4 \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\subsection{Lorem ipsum}%
\label{sub:lorem_ipsum}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultricies est sit amet interdum ornare. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nulla lectus, bibendum ultrices dui quis, sodales suscipit quam. Donec eu finibus lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Etiam eu metus mattis, bibendum massa quis, eleifend libero. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc lacinia ipsum at dolor tristique convallis. Sed dignissim malesuada nunc, nec malesuada risus sagittis eu. Nulla et erat et mi elementum scelerisque vitae at neque. Suspendisse scelerisque laoreet tellus, sit amet accumsan mauris placerat nec. Vestibulum mollis augue a odio posuere, ut gravida est lacinia. Etiam turpis ligula, molestie nec porta in, malesuada id magna. Donec elementum nulla ac tincidunt fringilla. Suspendisse porta laoreet nisl, non aliquam orci dictum egestas.
Proin euismod consequat felis ut pharetra. Maecenas auctor, nunc ac gravida pretium, metus mi fringilla lectus, auctor scelerisque nunc velit id magna. Etiam sit amet mi sit amet nunc congue ornare non hendrerit diam. Nullam consectetur lectus quis urna vehicula, nec lacinia tortor rhoncus. Vestibulum at enim aliquam, ultricies urna sit amet, porta tellus. Curabitur posuere elit orci, et rutrum nibh cursus eget. Donec ac venenatis purus. Fusce vehicula nisi erat, at tempor turpis congue vitae. Nunc auctor pellentesque malesuada. Nunc sodales, dolor ac sagittis mollis, enim ipsum mollis sem, non porttitor arcu nulla at velit. Ut non velit nec lacus sollicitudin maximus id id tortor. Sed ac aliquam lorem.
Nunc non ante ex. Curabitur lacinia euismod velit, non posuere leo bibendum non. Mauris ac orci non risus feugiat rutrum eu ac velit. Phasellus facilisis lacinia condimentum. Pellentesque vulputate nibh urna, vel varius mauris cursus quis. Aliquam vitae sem ac orci fermentum semper. Praesent est tellus, luctus sed venenatis at, bibendum id purus. Cras at mi sed lorem aliquet congue at sit amet turpis. Aliquam vestibulum tempor mauris, id aliquam ipsum scelerisque ut. In arcu turpis, dapibus ut nisi vel, luctus pellentesque felis. Aenean nisi erat, porttitor eu felis ut, imperdiet aliquam velit. Mauris vitae vehicula leo. Curabitur ut ante et ante pulvinar gravida. Donec tincidunt fringilla erat. Vivamus cursus augue et odio pharetra hendrerit.

View file

@ -0,0 +1,8 @@
%! TEX root = **/000-main.tex
% vim: spell spelllang=en:
\section{Appendix}
Appendix contents
\inputminted{cpp}{./code/P15601_en_Harrichu_y_and_the_maze.cc}

View file

@ -0,0 +1,41 @@
% vim: spell spelllang=en:
@article{einstein,
author = "Albert Einstein",
title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
}
@book{dirac,
title = {The Principles of Quantum Mechanics},
author = {Paul Adrien Maurice Dirac},
isbn = {9780198520115},
series = {International series of monographs on physics},
year = {1981},
publisher = {Clarendon Press},
keywords = {physics}
}
@online{knuthwebsite,
author = "Donald Knuth",
title = "Knuth: Computers and Typesetting",
url = "http://www-cs-faculty.stanford.edu/~uno/abcde.html",
addendum = "(accessed: 01.09.2016)",
keywords = "latex,knuth"
}
@inbook{knuth-fa,
author = "Donald E. Knuth",
title = "Fundamental Algorithms",
publisher = "Addison-Wesley",
year = "1973",
chapter = "1.2",
keywords = "knuth,programming"
}

View file

@ -0,0 +1,87 @@
# Build a reproducible latex document with latexmk, based on:
# https://flyx.org/nix-flakes-latex/
{ pkgs
# Document source
, src ? ./.
# Name of the final pdf file
, name ? "document.pdf"
# Use -shell-escape
, shellEscape ? false
# Use minted (requires shellEscape)
, minted ? false
# Additional flags for latexmk
, extraFlags ? [ ]
# Do not use the default latexmk flags. Usefull if you have a .latexmkrc or you
# don't want to use lualatex
, dontUseDefaultFlags ? false
# texlive packages needed to build the document
# you can also include other packages as a list.
, texlive ? pkgs.texlive.combined.scheme-full
# Pygments package to use (needed for minted)
, pygments ? pkgs.python39Packages.pygments
# Add system fonts
# you can specify one font directly with: pkgs.fira-code
# of join multiple fonts using symlinJoin:
# pkgs.symlinkJoin { name = "fonts"; paths = with pkgs; [ fira-code souce-code-pro ]; }
, fonts ? null
# Date for the document in unix time. You can change it
# to "$(date -r . +%s)" , "$(date -d "2022/02/22" +%s)", toString
# self.lastModified
, SOURCE_DATE_EPOCH ? "$(git log -1 --pretty=%ct)"
}:
let
inherit (pkgs) lib;
defaultFlags = [
"-interaction=nonstopmode"
"-pdf"
"-lualatex"
"-pretex='\\pdfvariable suppressoptionalinfo 512\\relax'"
"-usepretex"
];
flags = lib.concatLists [
(lib.optional (!dontUseDefaultFlags) defaultFlags)
extraFlags
(lib.optional shellEscape [ "-shell-escape" ])
];
in
assert minted -> shellEscape;
pkgs.stdenvNoCC.mkDerivation rec {
inherit src name;
buildInputs = [ texlive pkgs.git ] ++
lib.optional minted [ pkgs.which pygments ];
TEXMFHOME = "./cache";
TEXMFVAR = "./cache/var";
OSFONTDIR = lib.optionalString (fonts != null) "${fonts}/share/fonts";
buildPhase = ''
runHook preBuild
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH}" latexmk ${toString flags}
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -m644 -D *.pdf $out/${name}
runHook postInstall
'';
}

View file

@ -0,0 +1,51 @@
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
struct coord {
int x,y;
coord (int xx=0, int yy=0) : x(xx), y(yy) {}
bool operator== (const coord& p) {return x==p.x and y==p.y;}
} beg, goal;
int main () {
int n;
cin >> n;
while (n--) {
int r,c;
cin >> r >> c;
vector <vector <bool> > v (r, vector <bool> (c, 0));
for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j) {
char cc;
cin >> cc;
if (cc=='.') v[i][j]=true;
else if (cc=='b') beg = coord(i,j);
else if (cc=='g') goal = coord(i,j);
}
v[goal.x][goal.y] = v[beg.x][beg.y]=true;
vector <vector <bool> > f (v.size(),vector <bool> (v[0].size(),0));
queue <coord> q;
q.push(beg);
while (!q.empty()) {
coord p = q.front(); q.pop();
if (p.x>=v.size() or p.x<0 or p.y >= v[0].size() or p.y<0) continue;
if (!v[p.x][p.y]) continue;
if (f[p.x][p.y]) continue;
f[p.x][p.y] = true;
if (p==goal) break;
q.push(coord(p.x+1,p.y));
q.push(coord(p.x-1,p.y));
q.push(coord(p.x,p.y+1));
q.push(coord(p.x,p.y-1));
}
cout << (f[goal.x][goal.y]? "Good" : "Bad") << endl;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

78
templates/latex/flake.nix Normal file
View file

@ -0,0 +1,78 @@
# This template is based on https://github.com/Leixb/latex-template/tree/master
{
description = "LaTeX Flake";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
{
lib.latexmk = import ./build-document.nix;
} // flake-utils.lib.eachDefaultSystem (system:
let
pname = "document";
pkgs = import nixpkgs { inherit system; };
latex-packages = with pkgs; [
(texlive.combine {
inherit (texlive)
scheme-medium
framed
titlesec
cleveref
multirow
wrapfig
tabu
threeparttable
threeparttablex
makecell
environ
biblatex
biber
fvextra
upquote
catchfile
xstring
csquotes
minted
dejavu
comment
footmisc
xltabular
ltablex
;
})
which
python39Packages.pygments
];
dev-packages = with pkgs; [
texlab
zathura
wmctrl
];
in
rec {
devShell = pkgs.mkShell {
buildInputs = [ latex-packages dev-packages ];
};
formatter = pkgs.nixpgks-fmt;
packages = flake-utils.lib.flattenTree {
default = import ./build-document.nix {
inherit pkgs;
name = pname;
texlive = latex-packages;
shellEscape = true;
minted = true;
SOURCE_DATE_EPOCH = toString self.lastModified;
};
};
apps.default = flake-utils.lib.mkApp { drv = "${pkgs.texlivePackages.latexmk}"; exePath = "/bin/latexmk"; };
}
);
}

View file

@ -1,29 +0,0 @@
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{verbatim}
\usepackage{listings}
\author{Leon Schwarzäugl}
\date{\today}
\title{--NAME--}
\hypersetup{
pdfauthor={Leon Schwarzäugl},
pdftitle={--METADATA-NAME--},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 30.0.50 (Org mode 9.6.12)},
pdflang={English}}
\begin{document}
\end{document}