This commit is contained in:
Fl1tzi 2023-04-23 23:05:41 +02:00
parent e3130fb75d
commit b6c74f9064
5 changed files with 303 additions and 1 deletions

76
Makefile Normal file
View File

@ -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

132
README.md
View File

@ -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.
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!
```

9
content.md Normal file
View File

@ -0,0 +1,9 @@
---
title: "EXAMPLE"
---
# Example
This is some example text.
Please look at the README for explanation of the components.

9
refs.bib Normal file
View File

@ -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"
}

78
template.tex Normal file
View File

@ -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}