3

In math and science textbooks, we often have a main body of text that describes the principles, and interspersed throughout this text are examples. In upper-division and graduate texts, it seems like it's common simply to weave the examples into the text, whereas in freshman-level books they are usually set off from the main text by some graphical device. I think this is a good idea at the freshman level, because the audience is usually terrible at distinguishing basic principles from examples and trivia.

Below are some samples of this type of thing. Ideally I would like to have a package that would allow me to test-drive these styles just by changing one parameter in my class file. Is there such a thing? Or does anyone have a particular style, class, or package that has worked well for them? It's my experience that trying to do this kind of thing from scratch is often a lot of work to get right. Furthermore, styles like Grossman's seem difficult to manage without a lot of hand-tweaking of the visual design, because the different pieces of text in the margin end up colliding. I would also be happy to hear comments on the design and aesthetics.

like Grossman, Elementary linear algebra:

enter image description here

Kleppner and Kolenkow, An intro to mechanics:

enter image description here

Burke, Spacetime, geometry, cosmology

enter image description here

Morin, Intro to classical mechanics:

enter image description here

  • 1
    https://www.ctan.org/pkg/mdframed –  Jan 12 '17 at 18:14
  • 1
    related: http://tex.stackexchange.com/questions/135871/what-are-the-relative-strong-and-weak-points-between-tcolorbox-and-mdframed –  Jan 12 '17 at 19:03
  • Tcolorbox looks like the way to go for the simple examples. I'd still be interested in comments on the more complex possibilities, such as with stuff hanging out into the margins. –  Jan 13 '17 at 03:02

1 Answers1

2

Here is a tcolorbox version, to be updated...

I've defined two tcolorbox styles and a special tcolorbox environment for this, which uses \myboxstyle, which is some macro which can be set by a class or package option as well.

tcolorbox styles can be used within in each other, so the exampleboxoutline uses the same values of exampleboxfilled but specifies special values later on.

The second box example shows that the optional argument of the box can be used to use explicitly other styles or options.

\documentclass{article}

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

\tcbset{exampleboxfilled/.style={  enhanced jigsaw,
  sharp corners,
  colback=white!80!gray,
  colbacktitle=white!80!gray,
  fonttitle={\bfseries},
  coltitle=black,
  toprule=2pt,
  bottomrule=2pt,
  leftrule=0pt,
  rightrule=0pt,
  titlerule=0pt,
  left=0pt,
  right=0pt}
}


\tcbset{exampleboxoutline/.style={%  
    exampleboxfilled, % Use the filled style first
    colback=white,
    colbacktitle=white,
  }
}

\def\myboxstyle{exampleboxoutline}% To be set by a class option


\newtcolorbox[auto counter,number within=section]{examplebox}[2][]{%
  \myboxstyle,
  title={Example \thetcbcounter~#2},
  #1
}

\begin{document}

\section{Foo}

\begin{examplebox}{Rutherford Scattering}
  \blindtext
\end{examplebox}

\begin{examplebox}[exampleboxfilled]{Rutherford Scattering}
  \blindtext
\end{examplebox}


\end{document}

enter image description here