summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2019-12-05 21:20:03 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2019-12-05 21:20:03 +0100
commit6853f541261227cd0c93b345036474fa3b3141b7 (patch)
treee693bb98071e92c8f430549272a052cd08fd0b88
parent094764ff7610dce35e0334930ac79c2d8291f4d5 (diff)
Clean templates:
- Make listings force monochrome highlighting - Make 80-line code fit in width - Fix polyglossia language issues
-rw-r--r--pandoc/templates/elenq-article.latex67
-rw-r--r--pandoc/templates/elenq-book.latex77
2 files changed, 118 insertions, 26 deletions
diff --git a/pandoc/templates/elenq-article.latex b/pandoc/templates/elenq-article.latex
index c6d88b4..fdeab1d 100644
--- a/pandoc/templates/elenq-article.latex
+++ b/pandoc/templates/elenq-article.latex
@@ -18,7 +18,9 @@
%
% Expects some metadata to be set:
%
-% lang: english | spanish | basque | ...
+% polyglossia-lang:
+% name: english | spanish | basque | ...
+% lang: en-US | es-ES | ...
% title: The title of the document
% subtitle: The subtitle of the article
% author: Author's name
@@ -31,7 +33,10 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\documentclass[a4paper,11pt]{$documentclass$}
+\documentclass[a4paper,11pt
+$if(lang)$
+ $babel-lang$,
+$endif$]{$documentclass$}
\usepackage{tikz}
\newcommand{\logo}[1]{
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-{#1}, xscale={#1}, inner sep=0pt, outer sep=0pt]
@@ -149,10 +154,13 @@
\end{tikzpicture}
}
-% Language control from Metadata
$if(lang)$
-\usepackage{polyglossia}
-\setmainlanguage{$lang$}
+ % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
+ \usepackage{polyglossia}
+ \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
+ $for(polyglossia-otherlangs)$
+ \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
+ $endfor$
$endif$
% No indent
@@ -166,9 +174,6 @@ $endif$
headheight=30pt,
includeheadfoot=true]{geometry}
-% Color
-\usepackage{xcolor}
-
% Spacing
\usepackage{setspace}
@@ -194,6 +199,9 @@ $endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
+$if(lang)$
+ pdflang={$lang$},
+$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$; $endfor$},
$endif$
@@ -219,9 +227,46 @@ $if(verbatim-in-note)$
$endif$
% Syntax highlight
-$if(highlighting-macros)$
-$highlighting-macros$
-$endif$
+\usepackage{color}
+\usepackage{fancyvrb}
+\newcommand{\VerbBar}{|}
+\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
+\DefineVerbatimEnvironment{Highlighting}{Verbatim}{
+ commandchars=\\\{\},
+ fontsize=\footnotesize}
+\newenvironment{Shaded}{}{}
+\newcommand{\AlertTok}[1]{\textbf{#1}}
+\newcommand{\AnnotationTok}[1]{\textit{#1}}
+\newcommand{\AttributeTok}[1]{#1}
+\newcommand{\BaseNTok}[1]{#1}
+\newcommand{\BuiltInTok}[1]{#1}
+\newcommand{\CharTok}[1]{#1}
+\newcommand{\CommentTok}[1]{\textit{#1}}
+\newcommand{\CommentVarTok}[1]{\textit{#1}}
+\newcommand{\ConstantTok}[1]{#1}
+\newcommand{\ControlFlowTok}[1]{\textbf{#1}}
+\newcommand{\DataTypeTok}[1]{\underline{#1}}
+\newcommand{\DecValTok}[1]{#1}
+\newcommand{\DocumentationTok}[1]{\textit{#1}}
+\newcommand{\ErrorTok}[1]{\textbf{#1}}
+\newcommand{\ExtensionTok}[1]{#1}
+\newcommand{\FloatTok}[1]{#1}
+\newcommand{\FunctionTok}[1]{#1}
+\newcommand{\ImportTok}[1]{#1}
+\newcommand{\InformationTok}[1]{\textit{#1}}
+\newcommand{\KeywordTok}[1]{\textbf{#1}}
+\newcommand{\NormalTok}[1]{#1}
+\newcommand{\OperatorTok}[1]{#1}
+\newcommand{\OtherTok}[1]{#1}
+\newcommand{\PreprocessorTok}[1]{\textbf{#1}}
+\newcommand{\RegionMarkerTok}[1]{#1}
+\newcommand{\SpecialCharTok}[1]{#1}
+\newcommand{\SpecialStringTok}[1]{#1}
+\newcommand{\StringTok}[1]{#1}
+\newcommand{\VariableTok}[1]{#1}
+\newcommand{\VerbatimStringTok}[1]{#1}
+\newcommand{\WarningTok}[1]{\textit{#1}}
+
% Multiple page tables if needed
$if(tables)$
diff --git a/pandoc/templates/elenq-book.latex b/pandoc/templates/elenq-book.latex
index 3dcf2a3..23fadb0 100644
--- a/pandoc/templates/elenq-book.latex
+++ b/pandoc/templates/elenq-book.latex
@@ -18,7 +18,9 @@
%
% Expects some metadata to be set:
%
-% lang: english | spanish | basque | ...
+% polyglossia-lang:
+% name: english | spanish | basque | ...
+% lang: en-US | es-ES | ...
% title: The title of the document
% subtitle: The subtitle of the article
% author: Author's name
@@ -30,7 +32,10 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\documentclass[a4paper,11pt]{$documentclass$}
+\documentclass[a4paper,11pt,
+$if(lang)$
+ $babel-lang$,
+$endif$]{$documentclass$}
\usepackage{tikz}
\newcommand{\logo}[1]{
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-{#1}, xscale={#1}, inner sep=0pt, outer sep=0pt]
@@ -147,12 +152,16 @@
\end{scope}
\end{tikzpicture}}
-% Language control from Metadata
$if(lang)$
-\usepackage{polyglossia}
-\setmainlanguage{$lang$}
+ % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
+ \usepackage{polyglossia}
+ \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
+ $for(polyglossia-otherlangs)$
+ \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
+ $endfor$
$endif$
+
% No indent
\usepackage{parskip}
@@ -164,9 +173,6 @@ $endif$
headheight=30pt,
includeheadfoot=true]{geometry}
-% Color
-\usepackage{xcolor}
-
% Spacing
\usepackage{setspace}
@@ -192,6 +198,9 @@ $endif$
$if(author-meta)$
pdfauthor={$author-meta$},
$endif$
+$if(lang)$
+ pdflang={$lang$},
+$endif$
$if(keywords)$
pdfkeywords={$for(keywords)$$keywords$$sep$; $endfor$},
$endif$
@@ -217,9 +226,45 @@ $if(verbatim-in-note)$
$endif$
% Syntax highlight
-$if(highlighting-macros)$
-$highlighting-macros$
-$endif$
+\usepackage{color}
+\usepackage{fancyvrb}
+\newcommand{\VerbBar}{|}
+\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
+\DefineVerbatimEnvironment{Highlighting}{Verbatim}{
+ commandchars=\\\{\},
+ fontsize=\footnotesize}
+\newenvironment{Shaded}{}{}
+\newcommand{\AlertTok}[1]{\textbf{#1}}
+\newcommand{\AnnotationTok}[1]{\textit{#1}}
+\newcommand{\AttributeTok}[1]{#1}
+\newcommand{\BaseNTok}[1]{#1}
+\newcommand{\BuiltInTok}[1]{#1}
+\newcommand{\CharTok}[1]{#1}
+\newcommand{\CommentTok}[1]{\textit{#1}}
+\newcommand{\CommentVarTok}[1]{\textit{#1}}
+\newcommand{\ConstantTok}[1]{#1}
+\newcommand{\ControlFlowTok}[1]{\textbf{#1}}
+\newcommand{\DataTypeTok}[1]{\underline{#1}}
+\newcommand{\DecValTok}[1]{#1}
+\newcommand{\DocumentationTok}[1]{\textit{#1}}
+\newcommand{\ErrorTok}[1]{\textbf{#1}}
+\newcommand{\ExtensionTok}[1]{#1}
+\newcommand{\FloatTok}[1]{#1}
+\newcommand{\FunctionTok}[1]{#1}
+\newcommand{\ImportTok}[1]{#1}
+\newcommand{\InformationTok}[1]{\textit{#1}}
+\newcommand{\KeywordTok}[1]{\textbf{#1}}
+\newcommand{\NormalTok}[1]{#1}
+\newcommand{\OperatorTok}[1]{#1}
+\newcommand{\OtherTok}[1]{#1}
+\newcommand{\PreprocessorTok}[1]{\textbf{#1}}
+\newcommand{\RegionMarkerTok}[1]{#1}
+\newcommand{\SpecialCharTok}[1]{#1}
+\newcommand{\SpecialStringTok}[1]{#1}
+\newcommand{\StringTok}[1]{#1}
+\newcommand{\VariableTok}[1]{#1}
+\newcommand{\VerbatimStringTok}[1]{#1}
+\newcommand{\WarningTok}[1]{\textit{#1}}
% Multiple page tables if needed
$if(tables)$
@@ -283,9 +328,6 @@ $endif$
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
-% Copyleft symbol
-\newcommand{\copyleft}{\reflectbox{\copyright}}
-
% Prevent overfull lines
\setlength{\emergencystretch}{3em}
\providecommand{\tightlist}{
@@ -314,7 +356,7 @@ $endif$
\fancyfoot{} % clear footer
\renewcommand{\footrulewidth}{0.4pt}
\fancyfoot[RO, LE]{\thepage}
-\fancyfoot[LO, RE]{$if(license)$\textcopyleft $endif$ $author$}
+\fancyfoot[LO, RE]{$author$}
% Header on CHAPTER PAGE TODO
\fancypagestyle{chapter}{%
@@ -369,6 +411,11 @@ $endif$
\begin{document}
+% AVOID TIKZ ERROR -> MIGHT HAVE UNDESIRED RESULTS
+\makeatletter
+\global\let\tikz@ensure@dollar@catcode=\relax
+\makeatother
+
% Define cover
$if(title)$
\begin{titlepage}