4

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}
\DeclareInstance{exsheets-heading}{boxed}{default}{
     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)
        }
 }
 \SetupExSheets[question]{headings={boxed}}
 \SetupExSheets[solution]{headings={runin-nr}}

 \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
5

It's easier using the hooks:

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

\usepackage{tcolorbox}
\usepackage{exsheets}    

\SetupExSheets{
%  question/headings = {boxed} ,
  question/pre-hook = \begin{tcolorbox} ,
  question/pre-body-hook = \end{tcolorbox}\noindent ,
  solution/headings = {runin-nr}
}

\usepackage{lipsum}

\begin{document}

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

\lipsum[2]

\end{document}

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.