diff --git a/subject/colored-blocks.lua b/subject/colored-blocks.lua new file mode 120000 index 0000000..aec2d01 --- /dev/null +++ b/subject/colored-blocks.lua @@ -0,0 +1 @@ +../tutorial/colored-blocks.lua \ No newline at end of file diff --git a/subject/virli.sty b/subject/virli.sty new file mode 120000 index 0000000..7ca4038 --- /dev/null +++ b/subject/virli.sty @@ -0,0 +1 @@ +../tutorial/virli.sty \ No newline at end of file diff --git a/tutorial/colored-blocks.lua b/tutorial/colored-blocks.lua new file mode 100644 index 0000000..f943420 --- /dev/null +++ b/tutorial/colored-blocks.lua @@ -0,0 +1,47 @@ +function Div(el) + if el.classes[1] == "warning" + then + -- insert element in front + table.insert( + el.content, 1, + pandoc.RawBlock("latex", "\\begin{alertbox}")) + -- insert element at the back + table.insert( + el.content, + pandoc.RawBlock("latex", "\\end{alertbox}")) + + elseif el.classes[1] == "code" + then + -- insert element in front + table.insert( + el.content, 1, + pandoc.RawBlock("latex", "\\begin{codebox}")) + -- insert element at the back + table.insert( + el.content, + pandoc.RawBlock("latex", "\\end{codebox}")) + + elseif el.classes[1] == "question" + then + -- insert element in front + table.insert( + el.content, 1, + pandoc.RawBlock("latex", "\\begin{questionbox}")) + -- insert element at the back + table.insert( + el.content, + pandoc.RawBlock("latex", "\\end{questionbox}")) + + elseif el.classes[1] == "more" + then + -- insert element in front + table.insert( + el.content, 1, + pandoc.RawBlock("latex", "\\begin{morebox}")) + -- insert element at the back + table.insert( + el.content, + pandoc.RawBlock("latex", "\\end{morebox}")) + end + return el +end diff --git a/tutorial/header.tex b/tutorial/header.tex index ce4daef..0392eae 100644 --- a/tutorial/header.tex +++ b/tutorial/header.tex @@ -25,8 +25,8 @@ \usepackage{etoolbox} -% Declare coloredbox -\newcommand{\coloredbox}[2]{#2} +\usepackage{tcolorbox} +\usepackage{../virli} \makeatletter \pretocmd{\subsection}{\addtocontents{toc}{\protect\addvspace{-5\p@}}}{}{} diff --git a/tutorial/pandoc-opts.mk b/tutorial/pandoc-opts.mk index 63be051..f5419a7 100644 --- a/tutorial/pandoc-opts.mk +++ b/tutorial/pandoc-opts.mk @@ -14,4 +14,5 @@ PANDOCOPTS = --pdf-engine=lualatex \ -M indent=true \ -V toc-title="Sommaire" \ -V pdfa \ + --lua-filter=../colored-blocks.lua \ --include-in-header=../../tutorial/header.tex diff --git a/tutorial/virli.sty b/tutorial/virli.sty new file mode 100644 index 0000000..ea6fad8 --- /dev/null +++ b/tutorial/virli.sty @@ -0,0 +1,44 @@ +\tcbuselibrary{skins,breakable} +\newtcbox{\section@box}{tile,before=\noindent,after=, + fontupper=\normalfont\Large\bfseries,capture=minipage,colback=ForestGreen!80,coltext=white, + boxsep=0mm,top=4mm,bottom=4mm,left=\oddsidemargin+1in,right=\oddsidemargin+1in, + spread sidewards,fuzzy halo=1mm with ForestGreen!50!black} + +\renewcommand\section{\@startsection{section}{1}{\z@}{\z@}{5mm}{\section@box}} + +\newtcolorbox{alertbox}[1][]{breakable,enhanced, + before skip balanced=2mm,after skip balanced=3mm, + tile,left=11mm,right=2mm,top=1mm,bottom=1mm, + colback=white!0, + sharp corners, + underlay={% + \path[fill=OrangeRed!80!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=10mm]interior.north west); + },#1} + +\newtcolorbox{codebox}[1][]{breakable,enhanced, + before skip balanced=2mm,after skip balanced=3mm, + tile,left=11mm,right=2mm,top=1mm,bottom=1mm, + colback=white!0, + sharp corners, + underlay={% + \path[fill=black,draw=none] (interior.south west) rectangle node[white]{\huge\bfseries\texttt >\_} ([xshift=10mm]interior.north west); + },#1} + +\newtcolorbox{questionbox}[1][]{breakable,enhanced, + before skip balanced=2mm,after skip balanced=3mm, + tile,left=11mm,right=2mm,top=1mm,bottom=1mm, + colback=white!0, + sharp corners, + underlay={% + \path[fill=MidnightBlue!85!gray,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries ?} ([xshift=10mm]interior.north west); + },#1} + +\newtcolorbox{morebox}[1][]{breakable,enhanced, + before skip balanced=2mm,after skip balanced=3mm, + tile,left=7mm,right=7mm,top=1mm,bottom=1mm, + colback=white!0, + sharp corners, + underlay={% + \path[fill=ForestGreen!50!white,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries (} ([xshift=6mm]interior.north west); + \path[fill=ForestGreen!50!white,draw=none] (interior.south east) rectangle node[white]{\Huge\bfseries )} ([xshift=6mm]interior.north east); + },#1}