2

I have created a "solution" environment for some lecture notes, and I am experiencing an unexplainable space between the word Solution, which is the title of an mdframed environment and the beginning of the solution, when I starts with a formula. My solution sometimes start with a formula and other with a sentence, so I cannot simply add a negative \vspace to solve the problem. Herewith an example: sorry if it is a bit long.

\documentclass{article}

\usepackage[dvipsnames,svgnames,table]{xcolor} \usepackage{tikz} \usepackage{mdframed}

\mdfdefinestyle{ExampleStyle}{% skipabove=\topskip, skipbelow=\topskip, innerbottommargin=2ex, linewidth=1pt, leftline=false, rightline=false, frametitlefont={\color{DarkBlue}\normalfont\bfseries}, frametitlerule=false, frametitlebackgroundcolor=White, backgroundcolor=White, linecolor=DarkBlue}

\mdfdefinestyle{SolutionStyle}{% skipabove=\topskip, skipbelow=\topskip, topline=false, roundcorner=10pt, frametitlefont={\color{DarkBlue}\normalfont\bfseries}, frametitle={Solution}, frametitlerule=true, frametitlebackgroundcolor=DarkBlue!10, backgroundcolor=DarkBlue!10, linecolor=DarkBlue!10, fontcolor=DarkBlue}

\usepackage{amsmath,amsthm}

\mdtheorem[style=ExampleStyle]{Example}{Example}[section] \newmdenv[style=SolutionStyle]{Solution}

\begin{document}

\begin{Example} Work out~$2 + 3\times 5$. \end{Example}

\begin{Solution} [ \begin{split} 2 + 3\times 5 &= 2 + 15 \cr &= 17 \end{split} ] \end{Solution} \end{document}

The outcome is the following:

enter image description here

Logos
  • 419
  • Waiting for a MWE :-) I know of a very similar problem in beamer: https://tex.stackexchange.com/q/172602/82917. I don't use mdframed a lot but I guess it's a similar issue. – campa Oct 09 '20 at 09:54
  • Thank you! You are actually right, but I have, let's say, a hundred examples and I really wish I could do it automatically. Is there any chance to be able to make the space adjustment automatic, somehow? – Logos Oct 09 '20 at 09:56
  • You have "ExampleStyle" and "SolutionStyle". Could you not just modify "SolutionStyle"? – Plergux Oct 09 '20 at 10:43
  • That's mainly because of split environment. If you use textual sentences, then I don't think it will render more space. – M S Oct 09 '20 at 11:45
  • Yup, but I often use split in that context because I am solving little expressions, derivatives, integrals. So I really hope I can make it work somehow. – Logos Oct 09 '20 at 12:28

0 Answers0