3

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?

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

1 Answer 1

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .