3

I'm using the shadethm package in order to have gray background for theorems. However, the outcome is not satisfactory because the margin is too narrow:

enter image description here

Can anyone show me how to change the margin of the shadethm package or show me another way to add shaded background to theorems while can specify margin?

  • 3
    Welcome to TeX.SE! I'd highly recommend having a look at the mdframed package- it has all kinds of settings that can be tweaked easily :) – cmhughes Mar 20 '13 at 16:40
  • @cmhughes, mdframed is quite good! Thank you for your recommendation! – HanXu Mar 21 '13 at 9:42
3

As cmhughes has mentioned, the mdframed package offers a lot more features and possibilities than shadethm, so I also suggest you to switch to mdframed. However, to answer your question, you can change the values for the lengths \shadeboxsep (controlling the distance between the start of color to start of text; in the four sides) and \shadetextwidth (width of the text body) , as in the following simple example in which I left 6pt between the frame and the text, but keeping the total width equal to \textwidth:

\documentclass{article}
\usepackage{shadethm}
\usepackage{lipsum}% just to generate text for the example

\newshadetheorem{theo}{Theorem}
\setlength\shadeboxsep{6pt} 
\setlength\shadedtextwidth{\dimexpr\textwidth-2\shadeboxsep\relax}

\begin{document}

\lipsum[4]
\begin{theo}
\lipsum[4]
\end{theo}

\end{document}

enter image description here

A simple example with mdframed, showing some of its features; in particular, the ability to control individually (for each of the four sides) the separation between the frame and the text (this cannot be done easily with shadethm):

\documentclass{article}
\usepackage{amsthm}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{lipsum}% just to generate text for the example

\newmdtheoremenv[
  hidealllines=true,
  innerleftmargin=8pt,%
  innerrightmargin=8pt,%
  innertopmargin=12pt,%
  innerbottommargin=12pt,%
  backgroundcolor=gray!50,%
  skipbelow=\baselineskip,%
  skipabove=\baselineskip]{theo}{Theorem}

\begin{document}

\lipsum[4]
\begin{theo}
\lipsum[4]
\end{theo}

\end{document}

enter image description here

1

I am the author of shadethm. It has been superceded, long ago. If you are starting a new project then you should use something else. (This is an answer because I am unable to comment.)

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.