Introduce colored boxes

This commit is contained in:
nemunaire 2021-10-05 17:23:48 +02:00
parent 8c402e6d65
commit 10c23c7294
6 changed files with 96 additions and 2 deletions

1
subject/colored-blocks.lua Symbolic link
View File

@ -0,0 +1 @@
../tutorial/colored-blocks.lua

1
subject/virli.sty Symbolic link
View File

@ -0,0 +1 @@
../tutorial/virli.sty

View File

@ -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

View File

@ -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@}}}{}{}

View File

@ -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

44
tutorial/virli.sty Normal file
View File

@ -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}