Commit b3b049d9 authored by burcharr's avatar burcharr 💬
Browse files

initial commit of hopefully usable thesis writing template

parent 010427a8
###############################################################################
## Setup (public)
###############################################################################
## Working directory
## In case this doesn't work, set the path manually (use absolute paths).
WORKDIR = /home/robin/Masterarbeit/repos/thesis_template
## Pandoc
## (Defaults to docker. To use pandoc and TeX-Live directly, create an
## environment variable `PANDOC` pointing to the location of your
## pandoc installation.)
PANDOC ?= docker run --rm -v $(WORKDIR):/pandoc pandoc-thesis pandoc
## Source files
## (Adjust to your needs. Order of markdown files in $(SRC) matters!)
META = md/metadata.yaml
SRC = md/introduction.md \
md/related_work.md \
md/methods.md \
md/results.md \
md/discussion.md \
md/conclusion.md
BIBFILE = bib/references.bib
APPENDIX = md/appendix.md
TARGET = thesis.pdf
###############################################################################
## Internal setup (do not change)
###############################################################################
## Auxiliary files
## (Do not change!)
TITLEPAGE = titlepage.tex
FRONTMATTER = frontmatter.tex
BACKMATTER = backmatter.tex
REFERENCES = references.md
TMP1 = $(TITLEPAGE:%.tex=__%.filled.tex)
TMP2 = $(FRONTMATTER:%.tex=__%.filled.tex)
TMP3 = $(BACKMATTER:%.tex=__%.filled.tex)
TMP = $(TMP1) $(TMP2) $(TMP3)
## Pandoc options
AUX_OPTS = --wrap=preserve
OPTIONS = -f markdown
OPTIONS += --pdf-engine=pdflatex
OPTIONS += --standalone
OPTIONS += -M lang=en-US
OPTIONS += --metadata-file=$(META)
OPTIONS += --include-in-header=$(TMP1)
OPTIONS += --include-before-body=$(TMP2)
OPTIONS += --include-after-body=$(TMP3)
OPTIONS += --filter pandoc-crossref # Robin addition...
OPTIONS += --citeproc
OPTIONS += -M bibliography=$(BIBFILE)
OPTIONS += -M link-citations=true
## download from https://www.zotero.org/styles
## cf. https://pandoc.org/MANUAL.html#citations
#OPTIONS += --csl=chicago-author-date-de.csl
#OPTIONS += --csl=chicago-note-bibliography.csl
OPTIONS += --csl=ieee.csl
#OPTIONS += --csl=oxford-university-press-note.csl
OPTIONS += --listings
OPTIONS += -V documentclass=scrbook
OPTIONS += -V papersize=a4
OPTIONS += -V fontsize=11pt
OPTIONS += -V classoption:open=right
OPTIONS += -V classoption:twoside=true
OPTIONS += -V classoption:cleardoublepage=empty
OPTIONS += -V classoption:clearpage=empty
OPTIONS += -V geometry:top=30mm
OPTIONS += -V geometry:left=25mm
OPTIONS += -V geometry:bottom=30mm
OPTIONS += -V geometry:width=150mm
OPTIONS += -V geometry:bindingoffset=6mm
OPTIONS += --toc
OPTIONS += --toc-depth=2
OPTIONS += --number-sections
OPTIONS += -V colorlinks=true
## Eisvogel (do not change!)
## https://github.com/Wandmalfarbe/pandoc-latex-template
OPTIONS += -V book=true
OPTIONS += -V titlepage=true
OPTIONS += -V toc-own-page=true
## Template variables
TEMPLATE_DL_DIR = .tmp_template_dl
EISVOGEL_TEMPLATE = eisvogel.tex
EISVOGEL_REPO = https://github.com/Wandmalfarbe/pandoc-latex-template
EISVOGEL_VERSION = ad404d0446
CLEANTHESIS_TEMPLATE = cleanthesis.sty
CLEANTHESIS_REPO = https://github.com/derric/cleanthesis
CLEANTHESIS_VERSION = 63d1fdd815
TEMPLATE_FILES = $(EISVOGEL_TEMPLATE) $(CLEANTHESIS_TEMPLATE)
###############################################################################
## Main targets (do not change)
###############################################################################
## Simple book layout
simple: $(TARGET)
## Use Eisvogel template (https://github.com/Wandmalfarbe/pandoc-latex-template)
eisvogel: TEMPLATE_FILE += $(EISVOGEL_TEMPLATE)
eisvogel: TEMPLATE_REPO += $(EISVOGEL_REPO)
eisvogel: TEMPLATE_VERSION += $(EISVOGEL_VERSION)
eisvogel: AUX_OPTS += -M eisvogel=true
eisvogel: OPTIONS += --template=$(EISVOGEL_TEMPLATE) $(AUX_OPTS)
eisvogel: OPTIONS += -V float-placement-figure=htbp
eisvogel: OPTIONS += -V listings-no-page-break=true
eisvogel: $(EISVOGEL_TEMPLATE) $(TARGET)
## Use Clean Thesis template (https://github.com/derric/cleanthesis)
cleanthesis: TEMPLATE_FILE += $(CLEANTHESIS_TEMPLATE)
cleanthesis: TEMPLATE_REPO += $(CLEANTHESIS_REPO)
cleanthesis: TEMPLATE_VERSION += $(CLEANTHESIS_VERSION)
cleanthesis: AUX_OPTS += -M cleanthesis=true -M cleanthesisbibfile=$(BIBFILE:%.bib=%)
cleanthesis: OPTIONS += --include-in-header=include-header.tex $(AUX_OPTS)
cleanthesis: $(CLEANTHESIS_TEMPLATE) $(TARGET)
## Build docker image ("pandoc-thesis") containing pandoc and TeX-Live
docker:
cd docker && make
## Clean-up: Remove temporary (generated) files and download folder
clean:
rm -rf $(TMP) $(TEMPLATE_DL_DIR)
## Clean-up: Remove also generated thesis and template files
distclean: clean
rm -f $(TARGET) $(TEMPLATE_FILES)
###############################################################################
## Auxiliary targets (do not change)
###############################################################################
## Download template files
$(TEMPLATE_FILES):
rm -rf $(TEMPLATE_DL_DIR)
git clone --quiet --single-branch --branch master --depth 100 $(TEMPLATE_REPO) $(TEMPLATE_DL_DIR)
cd $(TEMPLATE_DL_DIR) && git checkout --quiet $(TEMPLATE_VERSION)
cp $(TEMPLATE_DL_DIR)/$(TEMPLATE_FILE) ./$(TEMPLATE_FILE)
rm -rf $(TEMPLATE_DL_DIR)
## Build thesis
${TARGET}: $(SRC) $(REFERENCES) $(APPENDIX) $(META) $(BIBFILE) $(TMP)
$(PANDOC) ${OPTIONS} -o $@ $(SRC) $(REFERENCES) $(APPENDIX)
## Build auxiliary files (title page, frontmatter, backmatter, references)
$(TMP): __%.filled.tex: %.tex $(META)
$(PANDOC) $(AUX_OPTS) --template=$< --metadata-file=$(META) -o $@ $<
###############################################################################
## Declaration of phony targets
###############################################################################
.PHONY: simple eisvogel cleanthesis docker clean distclean
......@@ -14,8 +14,40 @@ A thesis template in order to write a thesis in Markdown / Latex using Pandoc Th
## Instructions:
### First steps
1. Make sure all prerequisites are installed and you can run the generation (using `make` in this folder)
2. Edit the files to your liking, a skeleton is layed out but it can be modified as you wish. I propose using one markdown file per chapter.
3. Edit the contents of `md/metadata.yaml` by filling in your name, thesis title, due date etc. (This is also where your abstract goes)
### Adding, Removing or Renaming markdown files
The Markdown files are all stored in `md/`. You can edit and rename them there, or create new ones. In order to add them, just enter them into the Makefile.
### Mixing latex and markdown syntax, using the template
You can freely use markdown and latex syntax at the same time! E.g. enumerations with 1. 2. 3. instead of the latex begin list etc.
- You can mix latex and markdown references (latex: \label{xy} \ref{xy}, md: #xy @xy)
- Citations with @citekey (citekey as in references.bib)
- Inline math with `$x = 4$`
- Images can be included with markdown or with latex to your liking
- Latex commands can be added where ever you want
- For images and tables, you can use the provided folders.
- Latex includes (of packages) must be added at the beginning of titelpage.tex
#### Building, cleaning
- use `make` to generate the thesis, into `thesis.pdf`
- use `make distclean` to clean up (delete) all generated files
- sometimes, if only "external" files have changed, one must clean before a new pdf is generated, as the changes are not detected by make.
@article{some_citekey_2021,
title = {Some paper title},
volume = {03},
issn = {0218-4823, 1793-21312},
url = {https://www.url.de/23093sd},
doi = {10.1142/xy238293289},
abstract = {probably a longer abstract},
pages = {107--116},
number = {2},
journaltitle = {International Journal of Uncertainty, Fuzziness and Knowledge-Based Systems},
shortjournal = {Int. J. Unc. Fuzz. Knowl. Based Syst.},
author = {Nice, Author},
urldate = {2021-02-31},
date = {2021-04},
langid = {english},
}
%------------------------------------- Custom Title (Back) Page --------------------
$if(cleanthesis)$
\clearpage
\customtitlebackpage
$endif$
%------------------------------------- Custom Title (Back) Page --------------------
%------------------------------------- Declaration Page ----------------------------
$if(declaration)$
\IfFileExists{declaration_high.pdf}{
\let\origdoublepage\cleardoublepage
\newcommand{\clearemptydoublepage}{%
\clearpage
{\pagestyle{empty}\origdoublepage}%
}
\cleardoublepage
\includepdf[pages=-]{declaration_high.pdf}
\cleardoublepage
}
{
\chapter*{Eidesstattliche Erklärung}
\thispagestyle{empty}
\vspace{2cm}
\noindent{$declaration$}
\vspace{2cm}
\makeatletter
\noindent ($author$)
Freiburg, den $date$
\makeatother
}
$endif$
%------------------------------------- Declaration Page ----------------------------
%------------------------------------- Custom Abstract Page ------------------------
$if(abstract-de)$
\cleardoublepage
\begin{minipage}{\linewidth}
\chapter*{Zusammenfassung}
%\addcontentsline{toc}{chapter}{Zusammenfassung}
$abstract-de$
$if(abstract-en)$
\chapter*{Abstract}
%\addcontentsline{toc}{chapter}{Abstract}
$abstract-en$
$endif$
\end{minipage}
\cleardoublepage
$endif$
%------------------------------------- Custom Abstract Page ------------------------
%------------------------------------- Acknowledgements Page -----------------------
$if(acknowledgements)$
\chapter*{Danksagung}
%\addcontentsline{toc}{chapter}{Danksagung}
$acknowledgements$
$endif$
%------------------------------------- Acknowledgements Page -----------------------
%------------------------------------- Restriction Note Page -----------------------
$if(restrictionnote)$
\chapter*{Sperrvermerk}
$restrictionnote$
$endif$
%------------------------------------- Restriction Note Page -----------------------
%------------------------------------- Clear page before TOC -----------------------
\cleardoublepage
%------------------------------------- Clear page before TOC -----------------------
%------------------------------------- Use Eisvogel Header/Footer ------------------
$if(eisvogel)$
$if(headeralternative)$
\newpairofpagestyles{headeralternative}{
\clearpairofpagestyles
\automark[section]{chapter}
\ihead[\headmark]{}
\ohead[]{\headmark}
\ifoot[\pagemark]{$author$}
\ofoot[$author$]{\pagemark}
}
\pagestyle{headeralternative}
$endif$
$endif$
%------------------------------------- Use Eisvogel Header/Footer ------------------
#! /bin/bash
git add md/*.md
git add img/*.pdf
git add img/*.jpg
git add img/*.png
git add thesis.pdf
git add tables/*.tex
git add backmatter.tex
git add frontmatter.tex
git add titlepage.tex
git add references.md
git add md/metadata.yaml
git add Makefile
git add bib/*.bib
git add git_all.sh
git commit -m "automatic writing commit ..."
git push
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">
<info>
<title>IEEE</title>
<id>http://www.zotero.org/styles/ieee</id>
<link href="http://www.zotero.org/styles/ieee" rel="self"/>
<link href="http://www.ieee.org/documents/style_manual.pdf" rel="documentation"/>
<link href="http://www.ieee.org/documents/auinfo07.pdf" rel="documentation"/>
<author>
<name>Michael Berkowitz</name>
<email>mberkowi@gmu.edu</email>
</author>
<contributor>
<name>Julian Onions</name>
<email>julian.onions@gmail.com</email>
</contributor>
<contributor>
<name>Rintze Zelle</name>
<uri>http://twitter.com/rintzezelle</uri>
</contributor>
<contributor>
<name>Stephen Frank</name>
<uri>http://www.zotero.org/sfrank</uri>
</contributor>
<contributor>
<name>Sebastian Karcher</name>
</contributor>
<category citation-format="numeric"/>
<category field="engineering"/>
<category field="generic-base"/>
<updated>2013-12-17T18:04:02+00:00</updated>
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
</info>
<locale xml:lang="en">
<terms>
<term name="chapter" form="short">ch.</term>
<term name="presented at">presented at the</term>
<term name="available at">available</term>
</terms>
</locale>
<!-- Macros -->
<macro name="edition">
<choose>
<if type="bill book chapter graphic legal_case legislation motion_picture paper-conference report song" match="any">
<choose>
<if is-numeric="edition">
<group delimiter=" ">
<number variable="edition" form="ordinal"/>
<text term="edition" form="short"/>
</group>
</if>
<else>
<text variable="edition" text-case="capitalize-first" suffix="."/>
</else>
</choose>
</if>
</choose>
</macro>
<macro name="issued">
<choose>
<if type="article-journal report" match="any">
<date variable="issued">
<date-part name="month" form="short" suffix=" "/>
<date-part name="year" form="long"/>
</date>
</if>
<else-if type=" bill book chapter graphic legal_case legislation motion_picture paper-conference song thesis" match="any">
<date variable="issued">
<date-part name="year" form="long"/>
</date>
</else-if>
<else>
<date variable="issued">
<date-part name="day" form="numeric-leading-zeros" suffix="-"/>
<date-part name="month" form="short" suffix="-" strip-periods="true"/>
<date-part name="year" form="long"/>
</date>
</else>
</choose>
</macro>
<macro name="author">
<names variable="author">
<name initialize-with=". " delimiter=", " and="text"/>
<label form="short" prefix=", " text-case="capitalize-first"/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
</substitute>
</names>
</macro>
<macro name="editor">
<names variable="editor">
<name initialize-with=". " delimiter=", " and="text"/>
<label form="short" prefix=", " text-case="capitalize-first"/>
</names>
</macro>
<macro name="locators">
<group delimiter=", ">
<text macro="edition"/>
<group delimiter=" ">
<text term="volume" form="short"/>
<number variable="volume" form="numeric"/>
</group>
<group delimiter=" ">
<number variable="number-of-volumes" form="numeric"/>
<text term="volume" form="short" plural="true"/>
</group>
<group delimiter=" ">
<text term="issue" form="short"/>
<number variable="issue" form="numeric"/>
</group>
</group>
</macro>
<macro name="title">
<choose>
<if type="bill book graphic legal_case legislation motion_picture song" match="any">
<text variable="title" font-style="italic"/>
</if>
<else>
<text variable="title" quotes="true"/>
</else>
</choose>
</macro>
<macro name="publisher">
<choose>
<if type=" bill book chapter graphic legal_case legislation motion_picture paper-conference song" match="any">
<group delimiter=": ">
<text variable="publisher-place"/>
<text variable="publisher"/>
</group>
</if>
<else>
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</else>
</choose>
</macro>
<macro name="event">
<choose>
<if type="paper-conference speech" match="any">
<choose>
<!-- Published Conference Paper -->
<if variable="container-title">
<group delimiter=", ">
<group delimiter=" ">
<text term="in"/>
<text variable="container-title" font-style="italic"/>
</group>
<text variable="event-place"/>
</group>
</if>
<!-- Unpublished Conference Paper -->
<else>
<group delimiter=", ">
<group delimiter=" ">
<text term="presented at"/>
<text variable="event"/>
</group>
<text variable="event-place"/>
</group>
</else>
</choose>
</if>
</choose>
</macro>
<macro name="access">
<choose>
<if type="webpage">
<choose>
<if variable="URL">
<group delimiter=". ">
<text term="online" prefix="[" suffix="]" text-case="capitalize-first"/>
<group delimiter=": ">
<text term="available at" text-case="capitalize-first"/>
<text variable="URL"/>
</group>
<group prefix="[" suffix="]" delimiter=": ">
<text term="accessed" text-case="capitalize-first"/>
<date variable="accessed">
<date-part name="day" form="numeric-leading-zeros" suffix="-"/>
<date-part name="month" form="short" suffix="-" strip-periods="true"/>
<date-part name="year" form="long"/>
</date>
</group>
</group>
</if>
</choose>
</if>
</choose>
</macro>
<macro name="page">
<group>
<label variable="page" form="short" suffix=" "/>
<text variable="page"/>
</group>
</macro>
<macro name="citation-locator">
<group delimiter=" ">
<choose>
<if locator="page">
<label variable="locator" form="short"/>
</if>
<else>
<label variable="locator" form="short" text-case="capitalize-first"/>
</else>
</choose>
<text variable="locator"/>
</group>
</macro>
<!-- Citation -->
<citation collapse="citation-number">
<sort>
<key macro="issued" sort="descending"/>
</sort>
<layout delimiter=", ">
<group prefix="[" suffix="]" delimiter=", ">
<text variable="citation-number"/>
<text macro="citation-locator"/>
</group>
</layout>
</citation>
<!-- Bibliography -->
<bibliography entry-spacing="0" second-field-align="flush">
<sort>
<key macro="issued" sort="descending"/>
</sort>
<layout suffix=".">
<!-- Citation Number -->
<text variable="citation-number" prefix="[" suffix="]"/>
<!-- Author(s) -->
<text macro="author" suffix=", "/>
<!-- Rest of Citation -->
<choose>
<!-- Specific Formats -->