## Allows extensions to contribute some content at the beginning of the preamble
#set ($uixs = $services.uix.getExtensions('org.xwiki.contrib.latex.Preamble.before', {'sortByParameter' : 'order'}))
#if ($uixs)
  #foreach ($uix in $uixs)
    $services.rendering.render($uix.execute(), 'latex/1.0')
  #end

#end
%% Language and font encodings
\usepackage[$latex.tool.language]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%% Used for strike through support
\usepackage[normalem]{ulem}
%% Used for image support
\usepackage{graphicx}
%% For the Code macro
%% Note: Needs to be loaded before csquotes
\usepackage{minted}
%% Use for quotes and to support nested quotes
\usepackage{csquotes}
%% For the message macros
\usepackage{pifont,mdframed}
%% For the TOC macro, to have local tocs
\usepackage{etoc}
%% For the Formula macro
\usepackage{amsmath}
%% For links to attachments (we embed the attachments and link to them)
\usepackage{attachfile}
%% For putting standalone blocks inside table cells and keeping table cells to a minimal width
\usepackage{varwidth}
%% For multiline captions including fragile commands
\usepackage[justification=centering, singlelinecheck=off]{caption}
%% Used for links
%% Note: Should be loaded last
\usepackage{hyperref}
%% For the container macro
\usepackage{multicol}
%% For supporting footnotes located in figures and inside tables
\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}
## Allows extensions to contribute some additional packages after default ones
#set ($uixs = $services.uix.getExtensions('org.xwiki.contrib.latex.Preamble.usepackage.after', {'sortByParameter' : 'order'}))
#foreach ($uix in $uixs)
  $services.rendering.render($uix.execute(), 'latex/1.0')
#end

%% Message macro environments

\newenvironment{xwikimessage}[2]
${SP}${SP}{\par\begin{mdframed}[linewidth=2pt,linecolor=#1,frametitle=#2]%
${SP}${SP}${SP}${SP}\begin{list}{}{\leftmargin=1cm
#foreach ($i in [1..19])${SP}#end\labelwidth=\leftmargin}\item[\Large\ding{43}]}
${SP}${SP}{\end{list}\end{mdframed}\par}

\newenvironment{xwikierror}[1]
${SP}${SP}{\begin{xwikimessage}{red}{#1}}
${SP}${SP}{\end{xwikimessage}}

\newenvironment{xwikiwarning}[1]
${SP}${SP}{\begin{xwikimessage}{yellow}{#1}}
${SP}${SP}{\end{xwikimessage}}

\newenvironment{xwikiinfo}[1]
${SP}${SP}{\begin{xwikimessage}{blue}{#1}}
${SP}${SP}{\end{xwikimessage}}

\newenvironment{xwikisuccess}[1]
${SP}${SP}{\begin{xwikimessage}{green}{#1}}
${SP}${SP}{\end{xwikimessage}}

\newcommand{\xwikiinfoinline}[1] {
\fcolorbox{blue}{white}{#1}}

\newcommand{\xwikiwarninginline}[1] {
\fcolorbox{yellow}{white}{#1}}

\newcommand{\xwikierrorinline}[1] {
\fcolorbox{red}{white}{#1}}

\newcommand{\xwikisuccessinline}[1] {
\fcolorbox{green}{white}{#1}}

%% Set the style of internal references (hyperref)
\hypersetup{colorlinks=true, linkcolor=black, urlcolor=blue}

%% Ensure that images have a max width of 95% of the line width
\makeatletter
\setkeys{Gin}{width=\ifdim\Gin@nat@width>\linewidth
${SP}${SP}0.95\linewidth
\else
${SP}${SP}\Gin@nat@width
\fi}
\makeatother

%% Define heading command so that it can be overridden easily
#if ("$!latex.properties.documentClass" == 'book')
  #set ($isBook = true)
#else
  #set ($isBook = false)
#end
\newcommand{\heading}[3][]{
${SP}${SP}\ifx#21
${SP}${SP}${SP}${SP}#if ($isBook)\chapter#1\{#3}#else\section#1{#3}#end

${SP}${SP}\else
${SP}${SP}\ifx#22
${SP}${SP}${SP}${SP}#if ($isBook)\section#1\{#3}#else\subsection#1{#3}#end

${SP}${SP}\else
${SP}${SP}\ifx#23
${SP}${SP}${SP}${SP}#if ($isBook)\subsection#1\{#3}#else\subsubsection#1{#3}#end

${SP}${SP}\else
${SP}${SP}\ifx#24
${SP}${SP}${SP}${SP}#if ($isBook)\subsubsection#1\{#3}#else\paragraph#1{#3}#end

${SP}${SP}\else
${SP}${SP}\ifx#25
${SP}${SP}${SP}${SP}#if ($isBook)\paragraph#1\{#3}#else\subparagraph#1{#3}#end

${SP}${SP}\ifnum#2>5
${SP}${SP}${SP}${SP}\subparagraph#1{#3}
${SP}${SP}\fi
${SP}${SP}\fi
${SP}${SP}\fi
${SP}${SP}\fi
${SP}${SP}\fi
${SP}${SP}\fi}

%% Define xwikihorizontalline command so that it can be overridden easily
\newcommand{\xwikihorizontalline}{
\noindent\rule{\textwidth}{0.4pt}\vspace{0.5\baselineskip}
}

%% Use LaTeX quotes by default
\MakeOuterQuote{"}##
##
## Allows extensions to contribute some content at the end of the preamble
#set ($uixs = $services.uix.getExtensions('org.xwiki.contrib.latex.Preamble.after', {'sortByParameter' : 'order'}))
#if ($uixs)

  #foreach ($uix in $uixs)
    $services.rendering.render($uix.execute(), 'latex/1.0')
  #end
#end