function Div(el)
 if FORMAT:match('latex') then
  if el.classes:includes('lab') then
   local b=pandoc.List{pandoc.RawBlock('latex','\\begin{labbox}')};b:extend(el.content);b:insert(pandoc.RawBlock('latex','\\end{labbox}'));return b
  elseif el.classes:includes('solution') then
   local b=pandoc.List{pandoc.RawBlock('latex','\\begin{solutionbox}')};b:extend(el.content);b:insert(pandoc.RawBlock('latex','\\end{solutionbox}'));return b
  elseif el.classes:includes('exercise') then
   local b=pandoc.List{pandoc.RawBlock('latex','\\par\\addvspace{6pt}\\noindent\\begin{minipage}{\\linewidth}\\hypertarget{'..el.identifier..'}{}')};b:extend(el.content);b:insert(pandoc.RawBlock('latex','\\end{minipage}\\par'));return b
  end
 end
end

local chapter_id = ""
function Header(el)
 if FORMAT:match('latex') and el.level==1 then chapter_id=el.identifier end
 if FORMAT:match('latex') and el.level==2 and pandoc.utils.stringify(el.content)=="Exercises" then
  if chapter_id=='protocols' or chapter_id=='simulation-algorithms' or chapter_id=='evidence' then return el end
  return {pandoc.RawBlock('latex','\\clearpage'),el}
 end
end
