I want to style my ExSheets questions with a box around the headings but I can't make it work. I got this far:

\documentclass[a4paper,11pt,oneside]{memoir}

\usepackage{tcolorbox}

\usepackage{exsheets}
pre-code=\begin{tcolorbox},
post-code=\end{tcolorbox},
join = {title[r,B]number[l,B](.333em,0pt) },
attach =
{
main[l,vc]title[l,vc](0pt,0pt) ;
main[r,vc]points[l,vc](\marginparsep,0pt)
}
}

\begin{document}

\begin{question}
First question.
\end{question}
\end{document}


I'm not really satisfied with the position of the box. How can I improve this so the box gets centered around the heading?

• I think \tcolorboxenvironment{question}{some options} is a possible bypass – user31729 Feb 5 '17 at 20:51
• It's better to use the hooks available for the question environment. – clemens Feb 6 '17 at 11:41

It's easier using the hooks:

\documentclass[a4paper,11pt,oneside]{memoir}

\usepackage{tcolorbox}
\usepackage{exsheets}

\SetupExSheets{
question/pre-hook = \begin{tcolorbox} ,
question/pre-body-hook = \end{tcolorbox}\noindent ,
}

\usepackage{lipsum}

\begin{document}

\begin{question}
\lipsum[1]
\end{question}

\lipsum[2]

\end{document}


• Maybe question/pre-hook = \vspace{\baselineskip}\begin{tcolorbox} – clemens Feb 6 '17 at 10:21
• That's perfect. I missed the pre-body-hook. – mstouby Feb 6 '17 at 14:33