PDF export (fully automated with make target)

Generate tex files directly with python, not relying on lektor
This commit is contained in:
relikd
2020-11-16 15:27:21 +01:00
parent 07bb189da3
commit 39dc3a3575
10 changed files with 234 additions and 124 deletions

View File

@@ -1,3 +1,7 @@
/*.aux
/*.log
/*.out
/*.toc
/dyn-*.tex
/pdf-de.pdf
/pdf-en.pdf
/setup-builddir.tex
/pdf-en.pdf

View File

@@ -1,7 +1,7 @@
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[ngerman]{babel}
\include{setup}
\include{setup-builddir} % load \def\builddir{}
\include{dyn-builddir} % load \def\builddir{}
\def\tIngredients{Zutaten}
\def\tRecipe{Rezept}
@@ -9,6 +9,5 @@
\begin{document}
\makefrontmatter
\graphicspath{{\builddir/de/}}
\include{\builddir/de/pdf-export}
\include{dyn-recipes-de}
\end{document}

View File

@@ -1,7 +1,7 @@
\documentclass[letter,12pt,twoside]{article}
\usepackage[english]{babel}
\include{setup}
\include{setup-builddir} % load \def\builddir{}
\include{dyn-builddir} % load \def\builddir{}
\def\tIngredients{Ingredients}
\def\tRecipe{recipe}
@@ -9,6 +9,5 @@
\begin{document}
\makefrontmatter
\graphicspath{{\builddir/en/}}
\include{\builddir/en/pdf-export}
\include{dyn-recipes-en}
\end{document}

View File

@@ -9,45 +9,20 @@
\usepackage{tocloft} % \cftbeforesecskip
\usepackage{ragged2e} % \RaggedRight
\usepackage{fontspec} % \setmainfont, \setsansfont, \setmonofont
\usepackage{microtype}
\usepackage{xurl}
\PassOptionsToPackage{hyphens}{url}
\usepackage[hidelinks]{hyperref}
%-------------------------------------------
% Defines & Geometry
%-------------------------------------------
\graphicspath{{\builddir/en/}}
\definecolor{red2}{HTML}{AA203A}
\definecolor{red3}{HTML}{EE6A84}
\usepackage{xurl}
\PassOptionsToPackage{hyphens}{url}
\usepackage{hyperref}
\renewcommand{\UrlFont}{\normalfont}
%% Use this if the font is _not_ installed on the system
%% but it requires the download of the additional fonts package
%% \setmonofont[Path=fonts/]{FiraSans-Light}
\setmainfont[
Path = fonts/,
BoldFont = Crimson-Bold,
ItalicFont = Crimson-Italic,
BoldItalicFont = Crimson-BoldItalic
]{Crimson-Roman}
\setsansfont[
Path = fonts/,
Scale = 0.95,
BoldFont = FiraSans-Medium,
ItalicFont = FiraSans-LightItalic,
BoldItalicFont = FiraSans-MediumItalic
]{FiraSans-Regular}
%% Use this if the font is installed on the system
%% this does not require additional fonts package
% \setmainfont[
% BoldFont = {Fira Sans Medium},
% ItalicFont = {Fira Sans Light Italic},
% BoldItalicFont = {Fira Sans Medium Italic}
% ]{Fira Sans Regular}
% \setmainfont[
% BoldFont = {Crimson Bold},
% ItalicFont = {Crimson Italic},
% BoldItalicFont = {Crimson Bold Italic}
% ]{Crimson Roman}
% Defines & Geometry
\def\marginwidth{60mm}
\def\marginsep{8.2mm}
\def\marginwoverflow{67mm} % -1.2mm for makebox
@@ -66,56 +41,117 @@
includemp,
% showframe
}
% \renewcommand{\footnotesep}{2.5ex}
\renewcommand{\footnoterule}{
\kern -2pt
\hrule width \textwidth height .2pt
\kern 1.8pt}
% spacing before & after
%-------------------------------------------
% Penalties
%-------------------------------------------
\doublehyphendemerits=10000 % No consecutive line hyphens
\brokenpenalty=10000 % No broken words across columns/pages
\widowpenalty=9999 % Almost no widows at bottom of page
\clubpenalty=9999 % Almost no orphans at top of page
\interfootnotelinepenalty=9999 % Almost never break footnotes
%-------------------------------------------
% Fonts
%-------------------------------------------
\renewcommand{\UrlFont}{\normalfont}
%% Use this if the font is _not_ installed on the system
%% but it requires the download of the additional fonts package
%% \setmonofont[Path=fonts/]{FiraSans-Light}
\setmainfont[
Path = fonts/,
BoldFont = {Crimson-Bold},
ItalicFont = {Crimson-Italic},
BoldItalicFont = {Crimson-BoldItalic}
]{Crimson-Roman}
\setsansfont[
Path = fonts/,
Scale = 0.95,
BoldFont = {FiraSans-Medium},
ItalicFont = {FiraSans-LightItalic},
BoldItalicFont = {FiraSans-MediumItalic}
]{FiraSans-Regular}
%% Use this if the font is installed on the system
%% this does not require additional fonts package
% \setmainfont[
% BoldFont = {Fira Sans Medium},
% ItalicFont = {Fira Sans Light Italic},
% BoldItalicFont = {Fira Sans Medium Italic}
% ]{Fira Sans Regular}
% \setmainfont[
% BoldFont = {Crimson Bold},
% ItalicFont = {Crimson Italic},
% BoldItalicFont = {Crimson Bold Italic}
% ]{Crimson Roman}
%-------------------------------------------
% Spacing in sections
%-------------------------------------------
\makeatletter
% footer
\renewcommand\@makefntext[1]{\noindent\makebox[0.5em][l]{\@makefnmark}#1}
% subsubsection
\renewcommand{\subsubsection}{%
\@startsection{subsubsection}{3}%
{\z@}{-2ex \@plus -1ex \@minus -1ex}{.2ex \@plus 1ex \@minus .2ex}%
{\normalfont\large\bfseries}%
}
% paragraph
\renewcommand{\paragraph}{%
\@startsection{paragraph}{4}%
{\z@}{1.5ex \@plus 1ex \@minus .2ex}{-.75em}%
{\z@}{1.5ex \@plus 1ex \@minus .2ex}{-.75em \@plus -1em \@minus -.5em}%
{\normalfont\normalsize\bfseries}%
}
% footer
\renewcommand\@makefntext[1]{\noindent\makebox[0.5em][l]{\@makefnmark}#1}
\makeatother
% adjust description environment
\setlist[description,enumerate,itemize]{%
% \titleformat*{\section}{\LARGE\bfseries} # titlesec
\setlength{\cftbeforesecskip}{.5ex} % spacing in TOC
%-------------------------------------------
% Spacing in enumerations
%-------------------------------------------
\setlist[description]{%
topsep=0.7\baselineskip,
itemsep=0pt,
% labelsep=*,
% itemindent=-2em,
% listparindent=-2em,
% leftmargin=0em,
font={\sffamily}
}
\setlist[enumerate,itemize]{leftmargin=1em,topsep=0\baselineskip,parsep=0pt}
\widowpenalty10000
\clubpenalty10000
\setlist[enumerate,itemize]{
topsep=0\baselineskip,
leftmargin=1em,
itemsep=1ex,
parsep=0pt
}
%-------------------------------------------
% Section & footnote numbering
%-------------------------------------------
% disable section numbering
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{1}
% \titleformat*{\section}{\LARGE\bfseries} # titlesec
\setlength{\cftbeforesecskip}{0.2em} % spacing in TOC
% \renewcommand{\footnotesep}{2.5ex}
\renewcommand{\footnoterule}{
\kern -2pt
\hrule width \textwidth height .2pt
\kern 1.8pt}
% Footer page numbering
\renewpagestyle{plain}{%
\setfoot[{\makebox[-\marginwoverflow][r]{\thepage}}][][]{}{}{{\makebox[-\marginwoverflow][l]{\thepage}}}
}
\pagestyle{plain}
% \graphicspath{{../src/content/}}
%-------------------------------------------
% Title page
%-------------------------------------------
\newcommand{\makefrontmatter}{
\begin{titlepage}
\setcounter{page}{0} % sets the number 0 on the first page in preview
\newgeometry{top=2.5cm,bottom=2.5cm,left=4cm,right=4cm}
\centering
\vspace*{.06\textheight}
@@ -134,7 +170,10 @@
\setcounter{page}{1}
}
%-------------------------------------------
% Custom commands
%-------------------------------------------
\newcommand{\meta}[2]{%
\vspace{-0.75em}%
~\includegraphics[height=2ex]{misc/icon-time}\enspace\ifx\relax#1\relax\else#1\fi%
@@ -146,8 +185,7 @@
\ifx\relax#1\relax\else{%
\enlargethispage{5.75ex}
\let\thefootnote\relax\footnotetext{%
\hspace{-.6em} Source: %
\ifx\relax#2\relax#1\else\href{#1}{#2}\fi%
\hspace{-.6em} Source: \ifx\relax#2\relax#1\else\href{#1}{#2}\fi%
}\fi%
}
}
@@ -156,7 +194,7 @@
\newcommand{\ingGroup}[1]{\vspace{.2ex}\item{\bfseries\color{red2}\hspace{-1em} #1}}
\newcommand{\ingName}[1]{{\color{red3}#1}}
\newcommand{\ingDetail}[1]{\emph{\footnotesize,#1}}
\newcommand{\pagelink}[1]{\tRecipe \tPagePrefix\,{\color{red2}\pageref{#1}}}
\newcommand{\pagelink}[1]{\tRecipe{} \tPagePrefix\,{\color{red2}\pageref{#1}}}
\newcommand{\recipelink}[2]{#2 (\tPagePrefix\,\pageref{#1})}
\newcommand{\external}[2]{#2\footnote{\href{#1}{#1}}}
% \newcommand{\external}[2]{#2\footnote{\url{#1}}}