From 77a3ffb7c02b6f21473ab7dd99a0ce7e66bb6645 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Thu, 4 Nov 2021 09:31:40 +0100 Subject: beamer: code listings improvements --- beamer/flake.nix | 1 + beamer/slides.md | 23 +++++++++++++++++-- beamer/template.latex | 62 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/beamer/flake.nix b/beamer/flake.nix index 3bfc9b3..97ae895 100644 --- a/beamer/flake.nix +++ b/beamer/flake.nix @@ -68,6 +68,7 @@ latexmk beamercolorthemeowl + tcolorbox environ fvextra pgfopts minted catchfile upquote xstring framed; beamertheme-metropolis = { pkgs = [ beamertheme-metropolis' ]; }; diff --git a/beamer/slides.md b/beamer/slides.md index 1dbce3c..2a70071 100644 --- a/beamer/slides.md +++ b/beamer/slides.md @@ -11,8 +11,8 @@ colortheme: owl # Light theme #colorthemeoptions: snowy -#mintedstyle: perldoc -#mintedstyle: xcode +#minted: +# style: perldoc links-as-notes: true beameroption: "show notes on second screen=right" @@ -45,6 +45,25 @@ These are some-notes Much content +## Set code title + +```{=latex} +\tcbset{title=My Title} +``` + +```haskell +main :: IO () +main = print . md5 . pack . unwords =<< getArgs + where + md5 x = hash x :: Digest MD5 +``` + +```{=latex} +\tcbset{title=} +``` + +## Blocks + ### Block This is an block diff --git a/beamer/template.latex b/beamer/template.latex index 09960e9..2b8db35 100644 --- a/beamer/template.latex +++ b/beamer/template.latex @@ -326,6 +326,8 @@ $if(pagestyle)$ \pagestyle{$pagestyle$} $endif$ +$if(beamer)$ +% Make toc brighter \setbeamercolor{section in toc}{ use=normal text, fg=normal text.fg @@ -334,12 +336,40 @@ $endif$ use=normal text, fg=normal text.fg } +% Add background to blocks +\setbeamercolor*{block title}{ + bg=normal text.bg!80!normal text.fg, +} +\setbeamercolor*{block body}{ + bg=normal text.bg!90!normal text.fg, +} +$else$ +\definecolor{normal text.fg}{named}{black} +\definecolor{normal text.bg}{named}{white} +% From Owl +\definecolor{OwlRed}{RGB}{ 255, 92, 168} +\definecolor{OwlGreen}{RGB}{ 90, 168, 0} +\definecolor{OwlBlue}{RGB}{ 0, 152, 233} +\definecolor{OwlYellow}{RGB}{ 242, 147, 24} +\colorlet{OwlViolet}{OwlRed!50!OwlBlue} +\colorlet{OwlBrown}{OwlRed!50!OwlGreen} +\colorlet{OwlOrange}{OwlRed!50!OwlYellow} +\colorlet{OwlCyan}{OwlGreen!50!OwlBlue} +\colorlet{red}{OwlRed} +\colorlet{green}{OwlGreen} +\colorlet{blue}{OwlBlue} +\colorlet{yellow}{OwlYellow} +\colorlet{violet}{OwlViolet} +\colorlet{brown}{OwlBrown} +\colorlet{orange}{OwlOrange} +\colorlet{cyan}{OwlCyan} +$endif$ \usepackage{fvextra} \usepackage[outputdir=build]{minted} -\usemintedstyle{$if(mintedstyle)$$mintedstyle$$else$inkpot$endif$} -\setminted{bgcolor=normal text.bg!90!normal text.fg,tabsize=4,breaklines} +\usemintedstyle{$if(minted.style)$$minted.style$$else$$if(beamer)$inkpot$else$perldoc$endif$$endif$} +\setminted{tabsize=4,breaklines,numbersep=3mm,linenos,highlightcolor=violet!40!normal text.bg} \setmonofont{Fira Code}[ Scale=0.87096774193548387, % 459/527 @@ -348,14 +378,28 @@ $endif$ StylisticSet={6,8}, ] -% Add background to blocks -\setbeamercolor*{block title}{ - bg=normal text.bg!80!normal text.fg, -} +\usepackage{tcolorbox} +\tcbuselibrary{skins,breakable} -\setbeamercolor*{block body}{ - bg=normal text.bg!90!normal text.fg, -} +\renewcommand{\theFancyVerbLine}{\ttfamily\scriptsize\textcolor{normal text.fg!60!normal text.bg}{\arabic{FancyVerbLine}}} + +\BeforeBeginEnvironment{minted}{\begin{tcolorbox}[ + breakable, + tile, + enhanced, + left=6mm, + colbacktitle=normal text.bg!80!normal text.fg, + coltitle=normal text.fg, + coltext=normal text.fg, + fonttitle=\ttfamily\bfseries, + colback=normal text.bg!90!normal text.fg, + overlay={ + \begin{tcbclipinterior} + \fill[normal text.bg!85!normal text.fg] (frame.south west) rectangle ([xshift=5mm]frame.north west); + \end{tcbclipinterior} + } +]} +\AfterEndEnvironment{minted}{\end{tcolorbox}} \makeatletter \def\verbatim@nolig@list{} -- cgit v1.2.3