From ee8bdd41c711013aa67183fce2886f597dbddf2d Mon Sep 17 00:00:00 2001
From: Ekaitz Zarraga <ekaitz@elenq.tech>
Date: Mon, 8 Apr 2024 13:22:34 +0200
Subject: Implement bibliography and references

---
 pandoc/templates/elenq-article.latex | 57 ++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

(limited to 'pandoc/templates/elenq-article.latex')

diff --git a/pandoc/templates/elenq-article.latex b/pandoc/templates/elenq-article.latex
index ee19f6c..e84f165 100644
--- a/pandoc/templates/elenq-article.latex
+++ b/pandoc/templates/elenq-article.latex
@@ -154,6 +154,33 @@ $endif$]{$documentclass$}
 \end{tikzpicture}
 }
 
+% References
+$if(csl-refs)$
+\newlength{\cslhangindent}
+\setlength{\cslhangindent}{1.5em}
+\newlength{\csllabelwidth}
+\setlength{\csllabelwidth}{3em}
+\newlength{\cslentryspacingunit} % times entry-spacing
+\setlength{\cslentryspacingunit}{\parskip}
+\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
+ {% don't indent paragraphs
+  \setlength{\parindent}{0pt}
+  % turn on hanging indent if param 1 is 1
+  \ifodd #1
+  \let\oldpar\par
+  \def\par{\hangindent=\cslhangindent\oldpar}
+  \fi
+  % set entry spacing
+  \setlength{\parskip}{#2\cslentryspacingunit}
+ }%
+ {}
+\usepackage{calc}
+\newcommand{\CSLBlock}[1]{#1\hfill\break}
+\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
+\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
+\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
+$endif$
+
 $if(lang)$
   % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
   \usepackage{polyglossia}
@@ -192,6 +219,18 @@ $endif$
 ]
 \newcommand{\euro}{€}
 
+% Bibliography
+$if(natbib)$
+\usepackage[$natbiboptions$]{natbib}
+\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
+$endif$
+$if(biblatex)$
+\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
+$for(bibliography)$
+\addbibresource{$bibliography$}
+$endfor$
+$endif$
+
 % Pretty hyperlinks
 \usepackage{hyperref}
 $if(colorlinks)$
@@ -454,6 +493,24 @@ $if(lof)$
 $endif$
 $body$
 
+%% Bibliography
+$if(natbib)$
+$if(bibliography)$
+$if(biblio-title)$
+  $if(has-chapters)$
+  \renewcommand\bibname{$biblio-title$}
+  $else$
+  \renewcommand\refname{$biblio-title$}
+  $endif$
+  \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
+$endif$
+$endif$
+$endif$
+
+$if(biblatex)$
+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
+$endif$
+
 $for(include-after)$
 $include-after$
 $endfor$
-- 
cgit v1.2.3

