0

I use some tcolorboxes in the solution section of a math paper. For some reason there is some vertical space added.

How can I align the solution number with the top of the tcolorbox?
(The red boxes in the following picture are the added space I don't want.)

Screenshot

enter image description here

MWE

\documentclass[12pt, a4paper]{scrbook}
\usepackage{exsheets}

\DeclareInstance{exsheets-heading}{hugeIndent}{default}{
  runin = true,
  attach = {main[r,vc]number[l,vc](-3em,0pt)}
}

\SetupExSheets{
  headings=hugeIndent,
  question/pre-hook=\begin{addmargin}[3em]{0cm},
  question/post-hook=\end{addmargin},
  solution/pre-hook=\begin{addmargin}[3em]{0cm},
  solution/post-hook=\end{addmargin},
  counter-within={section},
  counter-format=ch.se.qu[1]
}

\usepackage{tikz}
\usepackage[most]{tcolorbox}

\begin{document}
  \part{EXCERCISES}
    \chapter{Topic 1}

      \section{Section}

        \begin{question}[ID=111]
        I'm an excercise.
        \end{question}
        \begin{solution}
\tcbsidebyside[
    sidebyside adapt=left,
    blanker,
    sidebyside gap=0.5\baselineskip,
    sidebyside align=top seam
]
{
    \begin{tikzpicture}[scale=\linewidth/20cm, baseline=(current bounding box.north)]
        \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
        \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
        \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
    \end{tikzpicture}%
}
{
    Bad aligned!
}
        \end{solution}

      \section{Section}

        \begin{question}[ID=121]
        I'm an excercise.
        \end{question}
        \begin{solution}
\tcbsidebyside[
    sidebyside adapt=left,
    blanker,
    sidebyside gap=0.5\baselineskip,
    sidebyside align=top seam
]
{
    I'm a bad
}
{
    aligned solution.
}
        \end{solution}

        \begin{question}[ID=122]
        I'm an excercise.
        \end{question}
        \begin{solution}
        I'm a perfectly aligned solution.
        \end{solution}

  \setcounter{chapter}{0}
  \part{SOLUTIONS}

    \chapter{Topic 1}

      \section{Section}
        \printsolutions[byID={111}]

      \section{Section}
        \printsolutions[byID={121}]

       \section{Section}
        \printsolutions[byID={122}]

\end{document}
  • 1
    I'm not very familiar with tcolorbox but I believe you want its option nobeforeafter – clemens Jun 28 '16 at 9:31
  • 1
    Typically a tcolorbox starts a new paragraph. See the description of the before key. So you either need to avoid this or add some negative space with enlarge top initially by=\dimexpr-\parskip-\baselineskip\relax. – Ulrike Fischer Jun 28 '16 at 9:40
  • 2
    The value gets negative. before skip=\dimexpr-\parskip-\baselineskip\relax is better. And add \strut at the begin of text content. (But it is possible that the solution and content get separated by a page break, didn't check). – Ulrike Fischer Jun 28 '16 at 10:00
  • 1
    @TeXnician I will do it, but later this day. – Ulrike Fischer Jan 20 '18 at 8:50
  • 2
    That seemed to be an extremely long day. ;-) – Jürgen Apr 25 '18 at 10:02

Your Answer

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

Browse other questions tagged or ask your own question.