Modify pandoc assignment template

This commit is contained in:
coolneng 2019-05-11 03:40:12 +02:00
parent 2747366f4e
commit b8670fbe17
3 changed files with 117 additions and 79 deletions

View File

@ -1,91 +1,130 @@
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
\documentclass[12pt]{article}
% -----------------
% START OF PREAMBLE
% -----------------
\documentclass[12pt,a4paper]{scrartcl}
% Commands
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
% Packages
\usepackage{fontspec}
\usepackage{eurosym}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{upquote}
\usepackage{microtype}
\usepackage{longtable,booktabs}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage[normalem]{ulem}
\usepackage{fancyhdr}
\usepackage[setpagesize=false,
unicode=false,
colorlinks=true,
urlcolor=blue,
linkcolor=black]{hyperref}
\usepackage[scaled=.95]{helvet}
\usepackage{courier}
% Required fix for fancyhdr
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
% Fancy headers and footers settings
\pagestyle{fancy}
\lhead{$left-header$}
\rhead{$right-header$}
\usepackage{longtable}
\usepackage{booktabs}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\usepackage[english]{babel}
% Required for syntax highlighting
$highlighting-macros$
\usepackage{geometry}
\geometry{verbose,a4paper,tmargin=1.5cm,bmargin=1.5cm,lmargin=1.5cm,rmargin=1.5cm}
% Don't let images overflow the page
% Can still explicit set width/height/options for an image
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Make links footnotes instead of hotlinks
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
% Avoid problems with \sout in headers with hyperref:
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
% No paragraph indentation
% and set space between paragraphs
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\pagestyle{empty}
% No section numbering
$if(verbatim-in-note)$
\usepackage{fancyvrb}
$endif$
$if(fancy-enums)$
% -- Redefine labelwidth for lists; otherwise, the enumerate package will cause
% -- markers to extend beyond the left margin.
\makeatletter\AtBeginDocument{%
\renewcommand{\@listi}
{\setlength{\labelwidth}{4em}}
}\makeatother
\usepackage{enumerate}
$endif$
$if(tables)$
\usepackage{array}
% -- This is needed because raggedright in table elements redefines \\:
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}
\let\PBS=\PreserveBackslash
$endif$
% Redefine \includegraphics so that, unless explicit options are
% given, the image width will not exceed the width or the height of the page.
% Images get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter
\def\@seccntformat#1{%
\expandafter\ifx\csname c@#1\endcsname\c@section\else
\csname the#1\endcsname\quad
\fi}
\def\ScaleWidthIfNeeded{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\def\ScaleHeightIfNeeded{%
\ifdim\Gin@nat@height>0.9\textheight
0.9\textheight
\else
\Gin@nat@width
\fi
}
\makeatother
\setkeys{Gin}{width=\ScaleWidthIfNeeded,height=\ScaleHeightIfNeeded,keepaspectratio}%
$if(subscript)$
\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
$endif$
\usepackage[breaklinks=true]{hyperref}
\hypersetup{colorlinks,%
citecolor=blue,%
filecolor=blue,%
linkcolor=blue,%
urlcolor=blue}
$if(url)$
\usepackage{url}
$endif$
$if(numbersections)$
$else$
\setcounter{secnumdepth}{0}
$endif$
$if(verbatim-in-note)$
\VerbatimFootnotes % -- allows verbatim text in footnotes
$endif$
$for(header-includes)$
$header-includes$
$endfor$
% -----------------
% END OF PREAMBLE
% -----------------
\begin{document}
\begin{center}
\hfill \break%
$if(title)$\Huge{$title$}\\[0.5em]$endif$
$if(authors)$\Large{$authors$}\\[2.5em]$endif$
\end{center}
$if(title)$
\textsc{$title$ \hfill {$for(author)$$author$$sep$\\$endfor$} \\ \hfill {$date$}}
\rule{\linewidth}{0.4pt}
$endif$
$if(toc)$
\tableofcontents
$endif$
$if(alignment)$
\begin{$alignment$}
$endif$
$body$
%$if(alignment)$
\end{$alignment$}
$endif$
\end{document}

View File

@ -35,9 +35,8 @@ endsnippet
snippet ass "YAML metadata for assignment"
---
title: $1
authors: Amin Kasrou Aouam
left-header:
right-header: `date +%F`
author: Amin Kasrou Aouam
date: `date +%F`
---
endsnippet

View File

@ -38,7 +38,7 @@ let g:vim_markdown_math=1
"" Pandoc
autocmd FileType markdown nnoremap <silent> <F3> :<c-u>!pandoc %:p:S -o %:p:r:S.pdf --from markdown --template eisvogel --listings &<cr>
autocmd FileType markdown nnoremap <silent> <F4> :<c-u>!pandoc %:p:S -o %:p:r:S.pdf --from markdown --template handout &<cr>
autocmd FileType markdown nnoremap <silent> <F5> :<c-u>!pandoc %:p:S -o %:p:r:S.pdf -t beamer -V theme:metropolis --listings &<cr>
autocmd FileType markdown nnoremap <silent> <F5> :<c-u>!pandoc %:p:S -o %:p:r:S.pdf --from markdown --template assignment &<cr>
autocmd FileType markdown nnoremap <silent> <F6> :<c-u>!zathura %:p:r:S.pdf &<cr>
autocmd FileType markdown nnoremap <silent> <F7> :<c-u>!rm %:p:r:S.pdf &<cr>
"" Snippets