diff --git a/.github/workflows/docgen.yml b/.github/workflows/docgen.yml index c5055c6..1a79f2a 100644 --- a/.github/workflows/docgen.yml +++ b/.github/workflows/docgen.yml @@ -18,7 +18,7 @@ jobs: container: image: ghcr.io/addiva-elektronik/pandoc steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - name: Generate documentation diff --git a/Makefile b/Makefile index 0d18952..6f6e7ad 100644 --- a/Makefile +++ b/Makefile @@ -11,12 +11,15 @@ gitrev = $(shell git log -n 1 --pretty=format:-%h -- $< 2>/dev/null) gitdate = $(shell git log -n 1 --pretty=format:%as -- $< 2>/dev/null) gitver = $(repo):$(objhash)$(gitrev) args = --standalone --data-dir=$(docgen) --template=addiva -f markdown+implicit_figures+implicit_header_references -args += --resource-path $(shell dirname $<) -V data-dir="$(docgen)" -V gitrev="$(gitrev)" +args += --resource-path $(shell dirname $<) -V data-dir="$(docgen)" -V gitrev="$(gitrev)" -V colorlinks args += -V gitversion="$(gitver)" -V date="$(gitdate)" -V today="$(shell date --iso)" -V year=$(shell date +'%Y') html-args = -t html $(args) pdf-args = -t pdf $(args) --pdf-engine=xelatex --listings +ifdef V +pdf-args += --verbose +endif %.html: %.md pandoc $(html-args) -o $@ $< diff --git a/templates/addiva.latex b/templates/addiva.latex index 391cff4..e98ae0d 100644 --- a/templates/addiva.latex +++ b/templates/addiva.latex @@ -2,6 +2,7 @@ %% This is a LaTeX style package for technical documents. %% Version 1.0 Joachim Nilsson %% Version 2.0 Joachim Wiberg +%% Version 3.0 Joachim Wiberg %% %% This program can be redistributed and/or modified under the terms %% of the LaTeX Project Public License Distributed from CTAN archives @@ -13,12 +14,7 @@ \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref} \PassOptionsToPackage{hyphens}{url} $if(colorlinks)$ -\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor} -$endif$ -$if(dir)$ -$if(latex-dir-rtl)$ -\PassOptionsToPackage{RTLdocument}{bidi} -$endif$ +\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor} $endif$ $if(CJKmainfont)$ \PassOptionsToPackage{space}{xeCJK} @@ -28,9 +24,6 @@ $endif$ $if(fontsize)$ $fontsize$, $endif$ -$if(lang)$ - $babel-lang$, -$endif$ $if(papersize)$ $papersize$paper, $endif$ @@ -52,6 +45,9 @@ $if(background-image)$ \usebackgroundtemplate{% \includegraphics[width=\paperwidth]{$background-image$}% } +% In beamer background-image does not work well when other images are used, so this is the workaround +\pgfdeclareimage[width=\paperwidth,height=\paperheight]{background}{$background-image$} +\usebackgroundtemplate{\pgfuseimage{background}} $endif$ \usepackage{pgfpages} \setbeamertemplate{caption}[numbered] @@ -101,29 +97,24 @@ $endif$ $if(beamerarticle)$ \usepackage{beamerarticle} % needs to be loaded first $endif$ -$if(fontfamily)$ -\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} -$else$ -\usepackage{lmodern} -$endif$ +\usepackage{amsmath,amssymb} $if(linestretch)$ \usepackage{setspace} $endif$ -\usepackage{amssymb,amsmath} -\usepackage{ifxetex,ifluatex} -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +\usepackage{iftex} +\ifPDFTeX \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc} \usepackage[utf8]{inputenc} \usepackage{textcomp} % provide euro and other symbols \else % if luatex or xetex $if(mathspec)$ - \ifxetex - \usepackage{mathspec} + \ifXeTeX + \usepackage{mathspec} % this also loads fontspec \else - \usepackage{unicode-math} + \usepackage{unicode-math} % this also loads fontspec \fi $else$ - \usepackage{unicode-math} + \usepackage{unicode-math} % this also loads fontspec $endif$ % See fontspec package for details on syntax, notice Path is unused. % https://ctan.math.illinois.edu/macros/unicodetex/latex/fontspec/fontspec.pdf @@ -155,8 +146,41 @@ $endif$ ItalicFont=*-RegularIt, BoldItalicFont=*-BoldIt } - \defaultfontfeatures{Scale=MatchLowercase} + \defaultfontfeatures{Scale=MatchLowercase}$-- must come before Beamer theme \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1} +\fi +$if(fontfamily)$ +$else$ +$-- Set default font before Beamer theme so the theme can override it +\usepackage{lmodern} +$endif$ +$-- Set Beamer theme before user font settings so they can override theme +$if(beamer)$ +$if(theme)$ +\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} +$endif$ +$if(colortheme)$ +\usecolortheme{$colortheme$} +$endif$ +$if(fonttheme)$ +\usefonttheme{$fonttheme$} +$endif$ +$if(mainfont)$ +\usefonttheme{serif} % use mainfont rather than sansfont for slide text +$endif$ +$if(innertheme)$ +\useinnertheme{$innertheme$} +$endif$ +$if(outertheme)$ +\useoutertheme{$outertheme$} +$endif$ +$endif$ +$-- User font settings (must come after default font and Beamer theme) +$if(fontfamily)$ +\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} +$endif$ +\ifPDFTeX\else + % xetex/luatex font selection $if(mainfont)$ \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} $else$ @@ -177,7 +201,7 @@ $for(fontfamilies)$ $endfor$ $if(mathfont)$ $if(mathspec)$ - \ifxetex + \ifXeTeX \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} \else \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$} @@ -187,42 +211,47 @@ $else$ $endif$ $endif$ $if(CJKmainfont)$ - \ifxetex + \ifXeTeX \usepackage{xeCJK} \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} + $if(CJKsansfont)$ + \setCJKsansfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKsansfont$} + $endif$ + $if(CJKmonofont)$ + \setCJKmonofont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmonofont$} + $endif$ \fi $endif$ $if(luatexjapresetoptions)$ - \ifluatex + \ifLuaTeX \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset} \fi $endif$ $if(CJKmainfont)$ - \ifluatex + \ifLuaTeX \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec} \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$} \fi $endif$ \fi -$if(beamer)$ -$if(theme)$ -\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} -$endif$ -$if(colortheme)$ -\usecolortheme{$colortheme$} -$endif$ -$if(fonttheme)$ -\usefonttheme{$fonttheme$} -$endif$ -$if(mainfont)$ -\usefonttheme{serif} % use mainfont rather than sansfont for slide text -$endif$ -$if(innertheme)$ -\useinnertheme{$innertheme$} -$endif$ -$if(outertheme)$ -\useoutertheme{$outertheme$} -$endif$ +$if(zero-width-non-joiner)$ +%% Support for zero-width non-joiner characters. +\makeatletter +\def\zerowidthnonjoiner{% + % Prevent ligatures and adjust kerning, but still support hyphenating. + \texorpdfstring{% + \TextOrMath{\nobreak\discretionary{-}{}{\kern.03em}% + \ifvmode\else\nobreak\hskip\z@skip\fi}{}% + }{}% +} +\makeatother +\ifPDFTeX + \DeclareUnicodeCharacter{200C}{\zerowidthnonjoiner} +\else + \catcode`^^^^200c=\active + \protected\def ^^^^200c{\zerowidthnonjoiner} +\fi +%% End of ZWNJ support $endif$ % Use upquote if available, for straight quotes in verbatim environments \IfFileExists{upquote.sty}{\usepackage{upquote}}{} @@ -246,39 +275,7 @@ $endif$ $if(verbatim-in-note)$ \usepackage{fancyvrb} $endif$ -\usepackage[svgnames]{xcolor} -\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available -\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} -\hypersetup{ -$if(title-meta)$ - pdftitle={$title-meta$}, -$endif$ -$if(author-meta)$ - pdfauthor={$author-meta$}, -$endif$ -$if(lang)$ - pdflang={$lang$}, -$endif$ -$if(subject)$ - pdfsubject={$subject$}, -$endif$ -$if(keywords)$ - pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, -$endif$ -$if(colorlinks)$ - colorlinks=true, - linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, - filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$, - citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, - urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, -$else$ - hidelinks, -$endif$ - pdfcreator={LaTeX via pandoc}} -\urlstyle{same} % disable monospaced font for URLs -$if(verbatim-in-note)$ -\VerbatimFootnotes % allow verbatim text in footnotes -$endif$ +\usepackage{xcolor} $if(geometry)$ $if(beamer)$ \geometry{$for(geometry)$$geometry$$sep$,$endfor$} @@ -294,11 +291,6 @@ $if(listings)$ \newcommand{\passthrough}[1]{#1} \lstset{defaultdialect=[5.3]Lua} \lstset{defaultdialect=[x86masm]Assembler} -\usepackage{caption} -\captionsetup{justification=centering,singlelinecheck=false} -\usepackage[listings]{tcolorbox} -\renewcommand{\lstlistingname}{Figure} -\lstset{frame=single,captionpos=b,backgroundcolor=\color{WhiteSmoke},basicstyle=\footnotesize\ttfamily} $endif$ $if(lhs)$ \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} @@ -307,7 +299,11 @@ $if(highlighting-macros)$ $highlighting-macros$ $endif$ $if(tables)$ -\usepackage{longtable,booktabs} +\usepackage{longtable,booktabs,array} +$if(multirow)$ +\usepackage{multirow} +$endif$ +\usepackage{calc} % for calculating minipage widths $if(beamer)$ \usepackage{caption} % Make caption package work with longtable @@ -340,14 +336,17 @@ $if(graphics)$ \def\fps@figure{htbp} \makeatother $endif$ -$if(links-as-notes)$ -% Make links footnotes instead of hotlinks: -\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} +$if(svg)$ +\usepackage{svg} $endif$ $if(strikeout)$ -\usepackage[normalem]{ulem} -% Avoid problems with \sout in headers with hyperref -\pdfstringdefDisableCommands{\renewcommand{\sout}{}} +$-- also used for underline +\ifLuaTeX + \usepackage{luacolor} + \usepackage[soul]{lua-ul} +\else + \usepackage{soul} +\fi $endif$ \setlength{\emergencystretch}{3em} % prevent overfull lines \providecommand{\tightlist}{% @@ -357,6 +356,9 @@ $if(numbersections)$ $else$ \setcounter{secnumdepth}{-\maxdimen} % remove section numbering $endif$ +$if(subfigure)$ +\usepackage{subcaption} +$endif$ $if(beamer)$ $else$ $if(block-headings)$ @@ -374,34 +376,64 @@ $endif$ $if(pagestyle)$ \pagestyle{$pagestyle$} $endif$ -$for(header-includes)$ -$header-includes$ -$endfor$ -$if(document.approved)$ -$else$ -\usepackage{draftwatermark} +$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)$ -\ifxetex - % 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$ +\ifLuaTeX +\usepackage[bidi=basic]{babel} \else - \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel} -$if(babel-newcommands)$ - $babel-newcommands$ -$endif$ +\usepackage[bidi=default]{babel} +\fi +$if(babel-lang)$ +\babelprovide[main,import]{$babel-lang$} +$if(mainfont)$ +\ifPDFTeX +\else +\babelfont{rm}[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$} \fi $endif$ -$if(dir)$ -\ifxetex - % Load bidi as late as possible as it modifies e.g. graphicx - \usepackage{bidi} +$endif$ +$for(babel-otherlangs)$ +\babelprovide[import]{$babel-otherlangs$} +$endfor$ +$for(babelfonts/pairs)$ +\babelfont[$babelfonts.key$]{rm}{$babelfonts.value$} +$endfor$ +% get rid of language-specific shorthands (see #6817): +\let\LanguageShortHands\languageshorthands +\def\languageshorthands#1{} +$endif$ +$for(header-includes)$ +$header-includes$ +$endfor$ +\ifLuaTeX + \usepackage{selnolig} % disable illegal ligatures \fi -\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex +$if(dir)$ +\ifPDFTeX \TeXXeTstate=1 \newcommand{\RL}[1]{\beginR #1\endR} \newcommand{\LR}[1]{\beginL #1\endL} @@ -419,14 +451,51 @@ $for(bibliography)$ \addbibresource{$bibliography$} $endfor$ $endif$ -$if(csl-refs)$ -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} -\newenvironment{cslreferences}% - {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% - \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% - {\par} +$if(nocite-ids)$ +\nocite{$for(nocite-ids)$$it$$sep$, $endfor$} $endif$ +$if(csquotes)$ +\usepackage{csquotes} +$endif$ +\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}} +\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available +\urlstyle{$if(urlstyle)$$urlstyle$$else$same$endif$} +$if(links-as-notes)$ +% Make links footnotes instead of hotlinks: +\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}} +$endif$ +$if(verbatim-in-note)$ +\VerbatimFootnotes % allow verbatim text in footnotes +$endif$ +\hypersetup{ +$if(title-meta)$ + pdftitle={$title-meta$}, +$endif$ +$if(author-meta)$ + pdfauthor={$author-meta$}, +$endif$ +$if(lang)$ + pdflang={$lang$}, +$endif$ +$if(subject)$ + pdfsubject={$subject$}, +$endif$ +$if(keywords)$ + pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, +$endif$ +$if(colorlinks)$ + colorlinks=true, + linkcolor={$if(linkcolor)$$linkcolor$$else$Maroon$endif$}, + filecolor={$if(filecolor)$$filecolor$$else$Maroon$endif$}, + citecolor={$if(citecolor)$$citecolor$$else$Blue$endif$}, + urlcolor={$if(urlcolor)$$urlcolor$$else$Blue$endif$}, +$else$ +$if(boxlinks)$ +$else$ + hidelinks, +$endif$ +$endif$ + pdfcreator={LaTeX via pandoc}} $if(title)$ \title{$title$$if(thanks)$\thanks{$thanks$}$endif$} @@ -444,11 +513,7 @@ $endif$ \subtitle{$subtitle$} $endif$ \author{$for(author)$$author$$sep$ \and $endfor$} -$if(date)$ \date{$date$} -$else$ -\date{\today} -$endif$ $if(beamer)$ $if(institute)$ \institute{$for(institute)$$institute$$sep$ \and $endfor$} @@ -503,6 +568,7 @@ $endif$ %%%%%%%%%%%%%%%%%% % https://learnbyexample.github.io/customizing-pandoc/ %\usepackage{tcolorbox} +\usepackage[listings]{tcolorbox} \newtcolorbox{myquote}{colback=WhiteSmoke!5!white, colframe=WhiteSmoke!75!black} \renewenvironment{quote}{\begin{myquote}}{\end{myquote}} %%%%%%%%%%%%%%%%%% @@ -518,9 +584,9 @@ $endif$ % Page margins %\setlength{\voffset}{5mm} %\setlength{\topskip}{5mm} -\setlength{\topmargin}{-25mm} +\setlength{\topmargin}{-28mm} \setlength{\headheight}{41mm} -\addtolength{\textheight}{-20mm} +\addtolength{\textheight}{-17mm} \addtolength{\footskip}{5mm} \renewcommand{\footruleskip}{10pt} @@ -593,7 +659,7 @@ $endif$ \lhead{ \fancyplain{ \begin{tabular}[t]{p{\mywidth - 1cm}p{\mywidth + 1cm}} -\includegraphics[width=\mywidth - 2cm, height=24pt, keepaspectratio]{\companylogo} & % +\includegraphics[width=\mywidth - 2cm, height=22pt, keepaspectratio]{\companylogo} & % $if(document.organisation)$ % \begin{tabular}[b]{@{}l@{}}\vspace{0pt}\tiny Organisation \small \\ \small \companyname \end{tabular} $endif$ % @@ -608,7 +674,7 @@ $if(document)$ $endif$ }{ \begin{tabular}[t]{p{\mywidth - 1cm}p{\mywidth + 1cm}} -\includegraphics[width=\mywidth - 2cm, height=24pt, keepaspectratio]{\companylogo} & % +\includegraphics[width=\mywidth - 2cm, height=22pt, keepaspectratio]{\companylogo} & % $if(document.organisation)$ % \begin{tabular}[b]{@{}l@{}}\vspace{0pt}\tiny Organisation \small \\ \small \companyname \end{tabular} $endif$ % @@ -640,7 +706,6 @@ $endif$ \renewcommand{\plainheadrulewidth}{0.0 pt} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \begin{document} $if(has-frontmatter)$ \frontmatter @@ -684,12 +749,12 @@ $endif$ } $endif$ $endif$ -$if(lot)$ -\listoftables -$endif$ $if(lof)$ \listoffigures $endif$ +$if(lot)$ +\listoftables +$endif$ $if(linestretch)$ \setstretch{$linestretch$} $endif$