From b6c74f9064f91024c8e85a21eb376edc74bbcfd3 Mon Sep 17 00:00:00 2001 From: Fl1tzi Date: Sun, 23 Apr 2023 23:05:41 +0200 Subject: [PATCH] init --- Makefile | 76 +++++++++++++++++++++++++++++ README.md | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++- content.md | 9 ++++ refs.bib | 9 ++++ template.tex | 78 ++++++++++++++++++++++++++++++ 5 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 content.md create mode 100644 refs.bib create mode 100644 template.tex diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b401ea4 --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +BUILD_DIR=build +FILE=content + +pdf: + mkdir $(BUILD_DIR) -p + $(MAKE) pandoc + $(MAKE) tex + $(MAKE) biber + $(MAKE) tex + # ------------------- + # | PDF LATEX | + # ------------------- + $(MAKE) pdf-raw + +pdf-no-bib: + mkdir $(BUILD_DIR) -p + $(MAKE) pandoc + $(MAKE) tex + # ----------------------------- + # | PDF LATEX NO BIBLIOGRAPHY | + # ----------------------------- + $(MAKE) pdf-raw + +pdf-raw: + pdflatex --interaction nonstopmode -output-directory=$(BUILD_DIR) $(FILE).tex + + +biber: + # ------------------- + # | BIBER | + # ------------------- + biber --output-directory=$(BUILD_DIR) $(FILE).bcf + +pandoc: + # ------------------- + # | PANDOC | + # ------------------- + pandoc $(FILE).md \ + -V linkcolor:blue \ + -V geometry:a4paper \ + --template=./template.tex \ + --biblatex \ + --metadata=bibliography:refs.bib \ + --from=markdown+tex_math_single_backslash+tex_math_dollars+raw_tex \ + --to=latex \ + --output=$(BUILD_DIR)/$(FILE).tex + +pandoc-no-bib: + # -------------------------- + # | PANDOC NO BIBLIOGRAPHY | + # -------------------------- + pandoc $(FILE).md \ + -V linkcolor:blue \ + -V geometry:a4paper \ + --template=./template.tex \ + --from=markdown+tex_math_single_backslash+tex_math_dollars+raw_tex \ + --to=latex \ + --output=$(BUILD_DIR)/$(FILE).tex + +tex: + # ------------------- + # | LATEX | + # ------------------- + latex -interaction nonstopmode -output-directory=$(BUILD_DIR) $(BUILD_DIR)/$(FILE).tex + +clear: + rm $(BUILD_DIR)/$(FILE).toc || true + rm $(BUILD_DIR)/$(FILE).tex || true + rm $(BUILD_DIR)/$(FILE).out || true + rm $(BUILD_DIR)/$(FILE).log || true + rm $(BUILD_DIR)/$(FILE).dvi || true + rm $(BUILD_DIR)/$(FILE).bcf || true + rm $(BUILD_DIR)/$(FILE).aux || true + rm $(BUILD_DIR)/$(FILE).run.xml || true + rm $(BUILD_DIR)/$(FILE).blg || true + rm $(BUILD_DIR)/$(FILE).bbl || true diff --git a/README.md b/README.md index 8f3c905..cc150b8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,133 @@ +--- +lang: en-us +--- + # markdown-latex-pandoc -A combination of Markdown, Latex and Pandoc with a Makefile to put everything easily in a PDF. \ No newline at end of file +A combination of Markdown, Latex and Pandoc with a Makefile to put everything easily in a PDF. + +## Setup + +There is a Makefile in the root of this folder. To execute this you need to have make installed, and you need to be on a UNIX system. + +### PDF + +`make pdf` + +There is a preconfigured workflow for a PDF. Just run `make pdf` to enable all supported features. The PDF will be outputted to `data/content.pdf`. + +### PDF no bibliography + +`make pdf-no-bib` + +Same as PDF, just without supporting bibliography. + +### Pandoc + +`make pandoc` + +This will just create a .tex file. + +### Pandoc without bibliography + +`make pandoc-no-bib` + +Same as Pandoc, just without supporting bibliography. + +### Tex + +`make tex` + +This will run Latex on the .tex file. + +### Clear + +`make clear` + +Remove all build files in the build folder. + +## Options + +These are options for the YAML frontmatter. All are optional. + +To use these you have to put it in the first lines of your .md file. + +Example: + +```yaml +--- +title: "HELLO!" +author: "Fl1tzi" +--- +``` + +### title + +Specify the title of your document. This will also create a cover. + +Example: + +`title: "My awesome work"` + +### author + +Specify the author of the document. Only useful in combination with `title`. + +Example: + +`author: "Max Mustermann"` + +### toc + +Create a table-of-contents. + +Example: + +`toc: true` + +### toc-title + +Use a custom title in your TOC. + +Example: + +`toc-title: Gliederung` + +### bibliography + +With this option you specify where the bibliography file is located. The format has to be for Biblatex. + +Example: + +`bibliography: refs.bib` + +### bibliography-title + +Use a custom bibliography title. + +Example: + +`bibliography-title: Literaturverzeichnis` + +### include-before + +Allows you to apply custom settings in Latex before the actual document. + +Example: + +```yaml +include-before: | + \linespread{1.2} +``` + +### include-after + +Allows you to apply custom settings in Latex after the content in the body. + +Example: + +```yaml +include-after: | + Thank you for reading this document! +``` + diff --git a/content.md b/content.md new file mode 100644 index 0000000..6c43d67 --- /dev/null +++ b/content.md @@ -0,0 +1,9 @@ +--- +title: "EXAMPLE" +--- + +# Example + +This is some example text. + +Please look at the README for explanation of the components. diff --git a/refs.bib b/refs.bib new file mode 100644 index 0000000..1248bcb --- /dev/null +++ b/refs.bib @@ -0,0 +1,9 @@ +@misc{DestatisOfflineEinwohner, + title = "Example title", + author = "{No one}", + howpublished = "\url{example-url.some-site}", + year = 2023, + month = Jan, + day = 1, + note = "This is an example" +} diff --git a/template.tex b/template.tex new file mode 100644 index 0000000..d889c79 --- /dev/null +++ b/template.tex @@ -0,0 +1,78 @@ +\documentclass[12pt,a4paper]{article} + +\usepackage{lmodern} +\usepackage[dvipsnames]{xcolor} +\usepackage[ + unicode=true, + colorlinks=true, + urlcolor=blue, + linkcolor=black, + citecolor=black, +]{hyperref} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} + +\linespread{1.5} + +% MACROS +\newcommand{\todo}[1]{ + \centerline{ + \colorbox{YellowOrange}{\textbf{To-do} #1} + } + \vspace{0.5cm} +} + +% BIBLATEX +$if(bibliography)$ + \usepackage[ + style=authoryear-ibid, + backend=biber, + ]{biblatex} + \addbibresource{$bibliography$} +$endif$ + +$for(include-before)$ + $include-before$ +$endfor$ + +\begin{document} + +$if(title)$ + \begin{titlepage} + + \title{$title$} + $if(author)$ + \author{$author$} + $endif$ + \maketitle + \thispagestyle{empty} + + \end{titlepage} + \newpage +$endif$ + +% TOC +$if(toc)$ + $if(toc-title)$ + \renewcommand\contentsname{$toc-title$} + $endif$ + \tableofcontents + \newpage +$endif$ + +$body$ + +$if(bibliography)$ + $if(bibliography-title)$ + \renewcommand\refname{$bibliography-title$} + $endif$ + \newpage + \printbibliography +$endif$ + +$for(include-after)$ + $include-after$ +$endfor$ + +\end{document} +