summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/shadethm
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/shadethm
Initial commit
Diffstat (limited to 'macros/latex/contrib/shadethm')
-rw-r--r--macros/latex/contrib/shadethm/1st_read.me28
-rw-r--r--macros/latex/contrib/shadethm/colored.sth11
-rw-r--r--macros/latex/contrib/shadethm/shadein.sth12
-rw-r--r--macros/latex/contrib/shadethm/shadetest.pdfbin0 -> 90404 bytes
-rw-r--r--macros/latex/contrib/shadethm/shadetest.tex177
-rw-r--r--macros/latex/contrib/shadethm/shadethm-doc.pdfbin0 -> 265142 bytes
-rw-r--r--macros/latex/contrib/shadethm/shadethm-doc.tex203
-rw-r--r--macros/latex/contrib/shadethm/shadethm.sty497
8 files changed, 928 insertions, 0 deletions
diff --git a/macros/latex/contrib/shadethm/1st_read.me b/macros/latex/contrib/shadethm/1st_read.me
new file mode 100644
index 0000000000..4219e68740
--- /dev/null
+++ b/macros/latex/contrib/shadethm/1st_read.me
@@ -0,0 +1,28 @@
+Brief description of shadethm.sty. 24July95
+
+shadethm.sty is a LaTeX2e package that allows declarations of the form
+ \newshadetheorem{thm}{Theorem}
+ or \newshadetheorem{}[]{}
+ or \newshadetheorem{}{}[]
+to produce shaded boxes from the usual command \begin{theorem} .. \end{theorem}
+(It is an upgrade of my LaTeX2.09 style file that did roughly the same thing.)
+The shaded boxes can, of course, be set to different sizes and colors. The
+color package is required.
+
+Brief Usage: Put the files where your LaTeX2e looks for .sty files, then:
+ \documentclass{article}
+ \usepackage{shadethm}
+ \newtheorem{lem}{Lemma}
+ \newshadetheorem{thm}{Theorem}
+ \begin{document}
+ \begin{lem} aaaaaaa \end{lemma}
+ \begin{thm} bbbbbb bbbbbb \end{thm}
+ \end{document}
+produces a LaTeX lemma, not shaded, and a LaTeX theorem, shaded.
+More instructions are in shadethm.sty.
+
+There are four files:
+ shadethm.sty, colored.sth, shadeins.sth, 1st_read.me;
+the second two provide package options to the first.
+
+hefferon@smcvax.smcvt.edu
diff --git a/macros/latex/contrib/shadethm/colored.sth b/macros/latex/contrib/shadethm/colored.sth
new file mode 100644
index 0000000000..d276f9374b
--- /dev/null
+++ b/macros/latex/contrib/shadethm/colored.sth
@@ -0,0 +1,11 @@
+\AtEndOfPackage{
+ \setlength{\shadeboxsep}{2pt}
+ \setlength{\shadeboxrule}{.4pt}
+ \setlength{\shadedtextwidth}{\textwidth}
+ \setlength{\shadeleftshift}{-\shadeboxsep}
+ \addtolength{\shadeleftshift}{-\shadeboxrule}
+ \setlength{\shaderightshift}{\shadeleftshift}
+ \definecolor{shadethmcolor}{cmyk}{0,.13,.11,0}
+ \definecolor{shaderulecolor}{cmyk}{0,0.88,0.85,0.35}
+}
+
diff --git a/macros/latex/contrib/shadethm/shadein.sth b/macros/latex/contrib/shadethm/shadein.sth
new file mode 100644
index 0000000000..e80120638a
--- /dev/null
+++ b/macros/latex/contrib/shadethm/shadein.sth
@@ -0,0 +1,12 @@
+\AtEndOfPackage{
+ \setlength{\shadeboxsep}{2pt}
+ \setlength{\shadedtextwidth}{\textwidth}
+ \addtolength{\shadedtextwidth}{-.5in}
+ \addtolength{\shadedtextwidth}{-2\shadeboxsep}
+ \setlength{\shadeleftshift}{.25in}
+ \setlength{\shaderightshift}{0in}
+ \definecolor{shadethmcolor}{gray}{.92}
+ \definecolor{shaderulecolor}{gray}{.92}
+ \setlength{\shadeboxrule}{0pt}
+}
+
diff --git a/macros/latex/contrib/shadethm/shadetest.pdf b/macros/latex/contrib/shadethm/shadetest.pdf
new file mode 100644
index 0000000000..9a8c902a77
--- /dev/null
+++ b/macros/latex/contrib/shadethm/shadetest.pdf
Binary files differ
diff --git a/macros/latex/contrib/shadethm/shadetest.tex b/macros/latex/contrib/shadethm/shadetest.tex
new file mode 100644
index 0000000000..3859c7df89
--- /dev/null
+++ b/macros/latex/contrib/shadethm/shadetest.tex
@@ -0,0 +1,177 @@
+\documentclass{article} % test of LaTeX package shadethm.sty
+\usepackage{shadethm}
+\newshadetheorem{theorem}{Theorem}[section]
+\newshadetheorem{cor}[theorem]{Corollary}
+\newtheorem{remark}[theorem]{Remark}
+\newtheorem{unshadedtheorem}[theorem]{Theorem}
+\newtheorem{comment}{Comment}[section]
+
+\begin{document}
+Document begins with some initial text.
+
+\section{First Section}
+Here is some initial text before the shaded box.
+
+\begin{theorem}
+This is the text to be shaded.
+\end{theorem}
+
+This is some text after the first shade.
+It is separated from the environments by a blank line; that is
+all handled as usual in \LaTeX.
+\begin{cor}
+This is more text to be shaded.
+It is numbered with the same counter as the environment above.
+
+Multiple paragraphs will be handled with the usual paragraph indentation,
+unless of course the user asks for a different paragraph indentation inside
+the environment.
+\end{cor}
+This is not separated from the prior environment by a blank line and
+so I don't expect a new paragraph.
+This shows that the default is for the shaded areas have the usual text size
+so that shading sticks out into the margin.
+This is the shadethm option \emph{bodymargin}.
+The behavior of having the shading end at the margin
+(so the words do not take up the full text width)
+comes from the option \emph{shademargin}, invoked with
+\verb!\usepackage[shademargin]{shadethm}!.
+
+
+\begin{unshadedtheorem}
+More text.
+This time not set in shade, but it is still numbered in the same sequence.
+\end{unshadedtheorem}
+
+A bit more.
+
+\begin{comment}
+More text.
+This time neither set in shade, nor numbered in the same sequence.
+\end{comment}
+
+
+\section{A New Section}
+
+Section preamble.
+
+\begin{theorem}
+This theorem is shaded and the number has been reset by the section.
+\end{theorem}
+
+\begin{remark}
+ And a closing remark
+\end{remark}
+Finishing text.
+
+\clearpage
+\section{A Test of Colors}
+This section shows how you can fool around to see some of you own colors.
+% Set up some lengths so that you can see the border.
+\setlength{\shadeboxsep}{2pt}
+\setlength{\shadeboxrule}{.4pt}
+\setlength{\shadedtextwidth}{\textwidth}
+\addtolength{\shadedtextwidth}{-2\shadeboxsep}
+\addtolength{\shadedtextwidth}{-2\shadeboxrule}
+\setlength{\shadeleftshift}{0pt}
+\setlength{\shaderightshift}{0pt}
+% Macro to test colors
+\newcommand{\thmwithcmykcolor}[2]{%
+\par Material before the theorem.
+\definecolor{shadethmcolor}{cmyk}{#1}%
+\definecolor{shaderulecolor}{cmyk}{#2}%
+\begin{theorem}
+This is a theorem set in the cmyk color \textbf{#1}, surrounded with a
+borderline set in the cmyk color \textbf{#2}.
+Note, for instance, that shades darken on overheads, so test your colors
+where you will use them.
+\end{theorem}}
+% Some colors
+\thmwithcmykcolor{.10,.10,0,0}{.75,.75,0,.5}
+\thmwithcmykcolor{.04,.04,0,.10}{.99,0,0.52,0.70}
+\thmwithcmykcolor{0,.13,.11,0}{0,0.88,0.85,0.35}
+The prior theorem illustrates what happens if you use the option
+\emph{colored}, as supplied in the file \verb!colored.sth!,
+except that the supplied file has the color stick out into the margin.
+
+One more supplied option is \emph{shadein} where each shaded theorem
+is indented, like a \LaTeX\ quotation.
+% ---> Uncomment if you want to test dvips's named colors
+% \newcommand{\thmwithnamedcolor}[1]{%
+% \par Material before the theorem.
+% \definecolor{shadethmcolor}{named}{#1}%
+% \definecolor{shaderulecolor}{named}{Black}%
+% \begin{theorem}
+% This is a theorem set in the named color \textbf{#1}, surrounded with a blac
+% borderline.
+% Note, for instance, that colors darken on overheads, so test your colors
+% where you will use them.
+% \end{theorem}}
+%
+% These are all the DVIPS named colors from color.pro (as of 1999-Aug-11).
+% \thmwithnamedcolor{GreenYellow}
+% \thmwithnamedcolor{Yellow}
+% \thmwithnamedcolor{Goldenrod}
+% \thmwithnamedcolor{Dandelion}
+% \thmwithnamedcolor{Apricot}
+% \thmwithnamedcolor{Peach}
+% \thmwithnamedcolor{Melon}
+% \thmwithnamedcolor{YellowOrange}
+% \thmwithnamedcolor{Orange}
+% \thmwithnamedcolor{BurntOrange}
+% \thmwithnamedcolor{Bittersweet}
+% \thmwithnamedcolor{RedOrange}
+% \thmwithnamedcolor{Mahogany}
+% \thmwithnamedcolor{Maroon}
+% \thmwithnamedcolor{BrickRed}
+% \thmwithnamedcolor{Red}
+% \thmwithnamedcolor{OrangeRed}
+% \thmwithnamedcolor{RubineRed}
+% \thmwithnamedcolor{WildStrawberry}
+% \thmwithnamedcolor{Salmon}
+% \thmwithnamedcolor{CarnationPink}
+% \thmwithnamedcolor{Magenta}
+% \thmwithnamedcolor{RedViolet}
+% \thmwithnamedcolor{Fuchsia}
+% \thmwithnamedcolor{Lavender}
+% \thmwithnamedcolor{Thistle}
+% \thmwithnamedcolor{Orchid}
+% \thmwithnamedcolor{DarkOrchid}
+% \thmwithnamedcolor{Purple}
+% \thmwithnamedcolor{Plum}
+% \thmwithnamedcolor{Violet}
+% \thmwithnamedcolor{RoyalPurple}
+% \thmwithnamedcolor{BlueViolet}
+% \thmwithnamedcolor{Periwinkle}
+% \thmwithnamedcolor{CadetBlue}
+% \thmwithnamedcolor{CornflowerBlue}
+% \thmwithnamedcolor{MidnightBlue}
+% \thmwithnamedcolor{NavyBlue}
+% \thmwithnamedcolor{RoyalBlue}
+% \thmwithnamedcolor{Blue}
+% \thmwithnamedcolor{Cerulean}
+% \thmwithnamedcolor{Cyan}
+% \thmwithnamedcolor{ProcessBlue}
+% \thmwithnamedcolor{SkyBlue}
+% \thmwithnamedcolor{Turquoise}
+% \thmwithnamedcolor{TealBlue}
+% \thmwithnamedcolor{Aquamarine}
+% \thmwithnamedcolor{BlueGreen}
+% \thmwithnamedcolor{Emerald}
+% \thmwithnamedcolor{JungleGreen}
+% \thmwithnamedcolor{SeaGreen}
+% \thmwithnamedcolor{Green}
+% \thmwithnamedcolor{ForestGreen}
+% \thmwithnamedcolor{PineGreen}
+% \thmwithnamedcolor{LimeGreen}
+% \thmwithnamedcolor{YellowGreen}
+% \thmwithnamedcolor{SpringGreen}
+% \thmwithnamedcolor{OliveGreen}
+% \thmwithnamedcolor{RawSienna}
+% \thmwithnamedcolor{Sepia}
+% \thmwithnamedcolor{Brown}
+% \thmwithnamedcolor{Gray}
+
+Enjoy!
+\textit{--Jim Hefferon}
+\end{document}
diff --git a/macros/latex/contrib/shadethm/shadethm-doc.pdf b/macros/latex/contrib/shadethm/shadethm-doc.pdf
new file mode 100644
index 0000000000..a82e7776a3
--- /dev/null
+++ b/macros/latex/contrib/shadethm/shadethm-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/shadethm/shadethm-doc.tex b/macros/latex/contrib/shadethm/shadethm-doc.tex
new file mode 100644
index 0000000000..26e1af15ad
--- /dev/null
+++ b/macros/latex/contrib/shadethm/shadethm-doc.tex
@@ -0,0 +1,203 @@
+\documentclass[pagesize=auto, fontsize=12pt, DIV=10]{scrartcl}
+
+\usepackage{fixltx2e}
+\usepackage{etex}
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage{microtype}
+\usepackage{hyperref}
+
+\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
+\makeatletter
+\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
+\makeatother
+\newcommand*{\env}[1]{\texttt{#1}}
+\newcommand*{\opt}[1]{\texttt{#1}}
+\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
+
+\renewcommand*{\labelenumi}{(\theenumi)}
+
+\addtokomafont{title}{\rmfamily}
+
+\title{The \pkg{shadethm} package}
+\subtitle{ Shaded theorem environments in \LaTeX,\\with \cmd{\newshadetheorem} in addition to \cmd{\newtheorem}}
+\author{Jim Hefferon\thanks{\mail{hefferon@smcvax.smcvt.edu}}}
+\date{1999/11/23}
+
+
+\begin{document}
+
+\maketitle
+
+
+\section{Usage}
+
+Used as a \LaTeXe\ style, with \verb|\usepackage{shadethm}|, it allows declarations
+of the form \verb|\newshadetheorem{theorem}{Theorem}|, so that
+%
+\begin{verbatim}
+\begin{theorem} $e=mc^2$ \end{theorem}
+\end{verbatim}
+%
+will produce the usual theorem, only placed in a shaded box.
+
+
+\minisec{Options.}
+
+Two come in this file:
+%
+\begin{description}
+\item[\opt{bodymargin} (default)]
+ The body of the shaded text lines up with the
+ margins. Just as though you called \verb|newtheorem|, then colored later.
+ Shading falls outside the margin.
+
+\item[\opt{shademargin}]
+ The shading lines up with the margins, so the body of
+ shaded text comes out a little thinner.
+\end{description}
+%
+If you call it with an option not on that list then it will look for a
+file \texttt{\meta{Option\-Name}.sth} and take the parameters from there. See the included
+files \texttt{shadein.sth} and \texttt{colored.sth}, the first of which gives theorems that are
+(like \LaTeX\ quotations) indented left and right and the second of which
+gives color shading.
+
+
+\section{Remarks}
+
+\begin{enumerate}
+\item You can of course have non-shaded environments, also. The \cmd{\newtheorem}
+ command still works.
+
+\item Numbering within: An prior version of this style required that you
+ number within like this:
+ %
+\begin{verbatim}
+\newshadetheorem{thm}{Theorem}
+\newshadetheorem{note}[shadethm]{Note} % No longer needed!
+\end{verbatim}
+ %
+ but this one drops that requirement. If you didn't use the old version,
+ forget about it.
+
+\item Uses the \pkg{graphics} package. Look for it in the \href{http://ctan.org/}{CTAN} \TeX-archive nearest
+ you, for instance at \href{http://tug.ctan.org/}{\texttt{tug.ctan.org}}.
+
+\item Works with \pkg{amsthm.sty}.
+
+\item Notice that if you say
+ %
+\begin{verbatim}
+\newshadetheorem{theorem}{Theorem}
+\end{verbatim}
+ %
+ and then
+ %
+\begin{verbatim}
+\newtheorem{theorem}{Theorem}
+\end{verbatim}
+ %
+ then you will get an error message since
+ the first allows you to say\\\verb|\begin{theorem} ...|, as does the second.
+\end{enumerate}
+
+
+\section{Installation}
+
+Put this where your \TeX\ looks for \texttt{.sty} files.
+There are some parameters you could set the default for (try them as is,
+first).
+%
+\begingroup
+\newcommand*{\desc}[1]{{\usekomafont{descriptionlabel}#1}\quad}%
+\renewcommand*{\theenumi}{\roman{enumi}}%
+\leftmargini = 1.5 \leftmargini
+\begin{enumerate}
+\item \label{item:i}\desc{\texttt{shadethmcolor}}
+ The shading color of the background. See the
+ documentation for the \pkg{color} package, but with a `gray' model, I~find .97
+ looks good out of my printer, while a darker shade like~.92 is needed
+ to make it copy well. (Black is~0, white is~1.)
+
+\item[(\ref{item:i}*)] \desc{\texttt{shaderulecolor}}
+ The shading color of the border of the shaded box.
+ See (\ref{item:i}). If \cmd{\shadeboxrule} is set to 0\,pt then this won't print anyway.
+
+\item[(\ref{item:i}**)] \desc{\cmd{\shadeboxrule}}
+ The width of the border around the shading. Set it to
+ 0\,pt (not just 0) to make it disappear.
+
+\item[(\ref{item:i}***)] \desc{\cmd{\shadeboxsep}}
+ The length by which the shade box surrounds the text.
+
+\item \desc{\cmd{\shadesetinsideminipage}}
+ The theorems are set inside a \env{minipage} to
+ get line breaks, but some things, like paragraph indents, are messed
+ with there, so I~have a hook to reset them. Probably you can just
+ leave this alone.
+
+\item The default option. Change the \verb|\ExecuteOptions{...}| right before
+ the \cmd{\ProcessOptions}.
+\end{enumerate}
+\endgroup
+
+
+\minisec{Comment:}
+
+If you get an error about `undefined color model' then you need to create
+the file \texttt{color.cfg} in the same place as \texttt{color.sty}, and put in it the line
+%
+\begin{verbatim}
+\ExecuteOptions{dvips}
+\end{verbatim}
+%
+(or~whatever is the name of your driver). See the
+documentation for the \pkg{graphics} package. I~needed this in the distant past
+under N\TeX.
+
+
+\section{Bugs}
+
+\begin{enumerate}
+\item Page breaks are a problem since it sets the theorem before it is shaded.
+ The theorem is put into a \env{minipage} in order to have the right line breaks
+ put in, but then can't be broken across pages. I'd be interested in any
+ fixes for this. DA?
+\end{enumerate}
+
+
+\section{License}
+
+Copyright 1999 Jim Hefferon \mail{jim@joshua.smcvt.edu}\\
+This program can redistributed and/or modified under the terms
+of the \LaTeX\ Project Public License Distributed from CTAN
+archives in directory \href{http://ctan.org/macros/latex/base/lppl.txt}{\nolinkurl{macros/latex/base/lppl.txt}}; either
+version~1 of the License, or (at your option) any later version.
+
+\clearpage
+
+
+\section{History}
+
+\begin{description}
+\item[\texttt{99XI23} jh] Redid the parsing to stick to \cmd{\newcommand}-style calls. Needed
+ to put in some oppresive \cmd{\expandafter} strings.
+\item[\texttt{99VII09} jh \mail{tex@joshua.smcvt.edu}] Fixed the number within situation. LPPL
+ added.
+\item[\texttt{97I07} jh] Changed the interior of the \cmd{\DeclareOptions} to \cmd{\AtBeginDocument}
+ for cases where the \cmd{\textwidth} is changed.
+\item[\texttt{95VI19} jh] Adapted for \LaTeXe. Now uses the \pkg{graphics} package, and all
+ the neat \LaTeXe\ package stuff. Still haven't rewritten the parsing code to
+ use the new optional arguments to \cmd{\newcommand}, though. Ah well.
+\item[\texttt{94VII11} jim hefferon \mail{hefferon@smcvax.smcvt.edu}.] First written (after lots
+ of sporadic tries, over months; I couldn't get any of the extant shading
+ macros to work with theorems) from a hint in TvZ's \texttt{Fancybox} writeup.
+ It's all so easy once you know how.
+\end{description}
+
+
+\end{document}
diff --git a/macros/latex/contrib/shadethm/shadethm.sty b/macros/latex/contrib/shadethm/shadethm.sty
new file mode 100644
index 0000000000..9da177c869
--- /dev/null
+++ b/macros/latex/contrib/shadethm/shadethm.sty
@@ -0,0 +1,497 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{shadethm}[1999/11/23]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% ShadeThm.sty
+% Shaded theorem environments in LaTeX, with \newshadetheorem in addition to
+% \newtheorem.
+%
+% USAGE
+% Used as a LaTeX2e style, with \usepackage{shadethm}, it allows declarations
+% of the form \newshadetheorem{theorem}{Theorem}, so that
+% \begin{theorem} $e=mc^2$ \end{theorem}
+% will produce the usual theorem, only placed in a shaded box.
+% Options. Two come in this file:
+% bodymargin (default) The body of the shaded text lines up with the
+% margins. Just as though you called newtheorem, then colored later.
+% Shading falls outside the margin.
+% shademargin The shading lines up with the margins, so the body of
+% shaded text comes out a little thinner.
+% If you call it with an option not on that list then it will look for a
+% file <OptionName>.sth and take the parameters from there. See the included
+% files shadein.sth and colored.sth, the first of which gives theorems that are
+% (like LaTeX quotations) indented left and right and the second of which
+% gives color shading.
+%
+% REMARKS
+% (1) You can of course have non-shaded environments, also. The \newtheorem
+% command still works.
+% (2) Numbering within: An prior version of this style required that you
+% number within like this:
+% \newshadetheorem{thm}{Theorem}
+% \newshadetheorem{note}[shadethm]{Note} % No longer needed!
+% but this one drops that requirement. If you didn't use the old version,
+% forget about it.
+% (3) Uses the graphics package. Look for it in the CTAN TeX-archive nearest
+% you, for instance at tug.ctan.org.
+% (4) Works with amsthm.sty.
+% (5) Notice that if you say \newshadetheorem{theorem}{Theorem} and then
+% \newtheorem{theorem}{Theorem} then you will get an error message since
+% the first allows you to say \begin{theorem} ..., as does the second.
+%
+% INSTALLATION
+% Put this where your TeX looks for .sty files.
+% There are some parameters you could set the default for (try them as is,
+% first).
+% (i) shadethmcolor The shading color of the background. See the
+% documentation for the color package, but with a `gray' model, I find .97
+% looks good out of my printer, while a darker shade like .92 is needed
+% to make it copy well. (Black is 0, white is 1.)
+% (i*) shaderulecolor The shading color of the border of the shaded box.
+% See (i). If \shadeboxrule is set to 0pt then this won't print anyway.
+% (i**) shadeboxrule The width of the border around the shading. Set it to
+% 0pt (not just 0) to make it disappear.
+% (i***) shadeboxsep The length by which the shade box surrounds the text.
+% (ii) shadesetinsideminipage The theorems are set inside a minipage to
+% get line breaks, but some things, like paragraph indents, are messed
+% with there, so I have a hook to reset them. Probably you can just
+% leave this alone.
+% (iii) The default option. Change the \ExecuteOptions{...} right before
+% the \ProcessOptions.
+% Comment:
+% If you get an error about `undefined color model' then you need to create
+% the file color.cfg in the same place as color.sty, and put in it the line
+% \ExecuteOptions{dvips} (or whatever is the name of your driver). See the
+% documentation for the graphics package. I needed this in the distant past
+% under NTeX.
+%
+% BUGS
+% (1) Page breaks are a problem since it sets the theorem before it is shaded.
+% The theorem is put into a minipage in order to have the right line breaks
+% put in, but then can't be broken across pages. I'd be interested in any
+% fixes for this. DA?
+%
+% LICENSE
+%% Copyright 1999 Jim Hefferon jim@joshua.smcvt.edu
+% This program can redistributed and/or modified under the terms
+% of the LaTeX Project Public License Distributed from CTAN
+% archives in directory macros/latex/base/lppl.txt; either
+% version 1 of the License, or (at your option) any later version.
+%
+% HISTORY
+% 99XI23 jh Redid the parsing to stick to \newcommand-style calls. Needed
+% to put in some oppresive \expandafter strings.
+% 99VII09 jh tex@joshua.smcvt.edu Fixed the number within situation. LPPL
+% added.
+% 97I07 jh Changed the interior of the \DeclareOptions to \AtBeginDocument
+% for cases where the \textwidth is changed.
+% 95VI19 jh Adapted for LaTeX2e. Now uses the graphics package, and all
+% the neat 2e package stuff. Still haven't rewritten the parsing code to
+% use the new optional arguments to \newcommand, though. Ah well.
+% 94VII11 jim hefferon hefferon@smcvax.smcvt.edu. First written (after lots
+% of sporadic tries, over months; I couldn't get any of the extant shading
+% macros to work with theorems) from a hint in TvZ's Fancybox writeup.
+% It's all so easy once you know how.
+%
+\DeclareOption{bodymargin}{
+ \AtEndOfPackage{%
+ \setlength{\shadeboxsep}{2pt}
+ \setlength{\shadeboxrule}{0pt}
+ \setlength{\shadedtextwidth}{\textwidth}
+ \setlength{\shadeleftshift}{-\shadeboxsep}
+ \setlength{\shaderightshift}{-\shadeboxsep}
+ \definecolor{shadethmcolor}{gray}{0.92}
+ \definecolor{shaderulecolor}{gray}{0.92}
+ }
+}
+\DeclareOption{shademargin}{
+ \AtEndOfPackage{%
+ \setlength{\shadeboxsep}{2pt}
+ \setlength{\shadeboxrule}{0pt}
+ \setlength{\shadedtextwidth}{\textwidth}
+ \addtolength{\shadedtextwidth}{-2\shadeboxsep}
+ \setlength{\shadeleftshift}{0pt}
+ \setlength{\shaderightshift}{0pt}
+ \definecolor{shadethmcolor}{gray}{0.92}
+ \definecolor{shaderulecolor}{gray}{0.92}
+ }
+}
+\DeclareOption*{\InputIfFileExists{\CurrentOption.sth}{}{%
+ \typeout{shadethm warning: option \CurrentOption\space not known.}}}
+
+\ExecuteOptions{bodymargin} %default
+\ProcessOptions
+
+\RequirePackage{color}
+
+% Save the document paragraph indents so they can be reasserted inside the
+% minipage into which the theorems get put.
+\newlength{\saveparindent} %to have paragraphs default to their
+\setlength{\saveparindent}{\parindent} %usual indent inside the minipage
+\newcommand{\shadesetinsideminipage}{% %To reset this inside an option,
+ \setlength{\parindent}{\saveparindent}} %or a document, \renewcommand{...}
+
+% Declare the lengths we need. Set in the package options.
+% Here is a diagram:
+% text text text text text text text text text text text text
+% ------------------------------------------------------
+% | Theorem. My bonnie lies over the ocean. My bonnie |
+% | lies over the sea. |
+% ------------------------------------------------------
+% --->| |<---- --->| |<--
+% \shadeleftshift \shadeboxsep
+% (all four sides)
+%
+% |<-------------- \shadetextwidth ---------------->|
+%
+\newlength{\shadeboxsep} %start of color to start of text; four sides
+\newlength{\shadeboxrule} %width of bordering rule
+\newlength{\shadedtextwidth} %width of the text body
+\newlength{\shadeleftshift} %margin to start of shading (may be negative)
+\newlength{\shaderightshift} %makes total line width come out (may be negative)
+
+
+% MAIN CODE
+% see LaTeXbook (second edition) pp 108 and 132
+% (1) make a box \saveshadebox that will hold the text that is to be
+% typeset in the theorem.
+% (2) Read that material in with the lrbox environment. The material
+% is set in a minipage so the margins are controllable.
+% (3) Use that box, inside of an fcolorbox.
+% Notes
+% * lrbox is used instead of savebox because this is an environment.
+% * The fcolorbox is inside a trivlist because that makes the vertical
+% spacing come out right. I don't know how else to do it.
+% * The fcolorbox is left shifted by some length (which may be negative) and
+% then aftward, a right shift is put in.
+\newsavebox{\shadesavebox} % no `@'; users can redefine shadebox if they want
+\newenvironment{shadebox}% % shadow boxes or something.
+{\begin{lrbox}{\shadesavebox}\begin{minipage}{\shadedtextwidth}%
+\shadesetinsideminipage}%
+{\end{minipage}\end{lrbox}%
+\begin{trivlist}\item[]% In a trivlist because theorems are in trivlists.
+\setlength{\fboxsep}{\shadeboxsep}%
+\setlength{\fboxrule}{\shadeboxrule}%
+\mbox{\hspace{\shadeleftshift}\fcolorbox{shaderulecolor}{shadethmcolor}{\usebox{\shadesavebox}}\hspace{\shaderightshift}}%
+\end{trivlist}}
+
+%PARSING CODE
+% The definition of \newshadetheorem is modelled on the one for \newtheorem
+% in latex.tex.
+% The invocation possibilities are:
+% \newshadetheorem{NAME}{TEXT}[COUNTER]
+% e.g., \newshadetheorem{theorem}{Theorem}[section] meaning to allow
+% one to say \begin{theorem} $e=mc^2$ \end{theorem} to produce
+% Theorem 1.1.1 e=mc2
+% shaded and numbered by section.
+% \newshadetheorem{NAME}[OLDNAME]{TEXT}
+% e.g., \newshadetheorem{remark}[theorem]{Remark} meaning to allow
+% one to say \begin{remark} Obvious. \end{remark} to produce
+% Remark 1.1.2 Obvious.
+% shaded and numbered with the same counter used for theorems.
+% \newcommand parsing
+% In LaTeX2e, to call a macro with an optional argument, let the
+% optional's default value be given in a second set of []'s:
+% \newcommand{\mymac}[2][hello]{#2, ``#1''} will have
+% \mymac{I say} |---> I say ``hello''
+% \mymac[goodbye]{You say} |---> You say ``goodbye''
+% I want to use this to parse LaTeX's
+% \newtheorem{--env_name--}{--caption--}[--within--]
+% or \newtheorem{--env_name--}[--numbered_like--]{--caption--}
+% So
+% (1) \newshadetheorem{arg1}
+% arg1: the environment name (e.g. definition)
+% It ends by calling a macro \sth@getcaption with one mandatory argument and
+% one optional argument.
+% (2) \sth@getcaption[oparg1]{arg1}
+% arg1: the caption name (e.g. Definition)
+% oparg1: the numbered_like (e.g., theorem)
+% It ends by calling a macro \sth@getwithin of no mandatory arguments but
+% one optional argument.
+% (3) \sth@getwithin[oparg1]
+% oparg1: the numbered within (e.g. subsection)
+% This routine finishes the processing. Depending on the four possibilities
+% of whether there is a numbered_like or not, and whether there is a
+% within or not, \newtheorem is called as is appropriate.
+% If there is no numbered_like, then the counter has to be set. That is,
+% a user expects to say \newtheorem{corollary}[theorem]{Corollary} and get
+% a corollary environment that is numbered in the same sequence as the
+% theorem environment, e.g., uses the theorem counter c@theorem. But in
+% runnning the \newshadetheorem we have called a \newtheorem{shadetheorem}...
+% and so the counter actually created is c@shadetheorem. We need the three
+% c@theorem, p@theorem and \thetheorem.
+% **** Remark on the \expandafter madness ****
+% Probably I am going about this all wrong ...
+% The construct
+% \newtheorem{\sth@envname}{\sth@caption}
+% doesn't do the job here because the \sth@envname and sth@caption aren't
+% resolved until they are called in the document:
+% after \newshadetheorem{theorem}{Theorem}
+% \newshadetheorem{corollary}{Corollary}
+% and later in the document
+% \begin{theorem} .. \end{theorem}
+% we get ``Corollary'' because that's what \sth@envname is at that moment.
+% Aarrg!
+% Instead, it has to be expanded when \newshadetheorem is called. This is
+% hard, IMHO. \expandafter<tok1><\tok2> puts <tok1> on a stack and expands
+% <tok2>. If <tok2> is another \expandafter then we have
+% \expandafter<tok1>\expandafter<tok3><tok4> which resolves to
+% <tok1><tok3><expansion of tok4>. If <tok1> is another \expandafter then
+% there is another round of expansion.
+% * To have \newshadetheorem{thm}{Thm} expand, we do this (where \ea is an
+% abbreviation for \expandafter):
+% \ea\ea\ea\newtheorem\ea\ea\ea{\ea\sth@shadeenvname\ea}\ea{\sth@caption}
+% ... which resolves to ...
+% \ea \newtheorem \ea { \sth@shadeenvname } {Thm }
+% ... which in turn resolves to ...
+% \newtheorem { thm } {Thm }
+% ... which is what I want.
+% * To have a three-argument case come out right, we need seven \ea's.
+% Consider the one that we want to come out as \newtheorem{thm}{Thm}[section].
+% \ea\ea\ea\ea\ea\ea\ea\newtheorem\ea\ea\ea\ea\ea\ea\ea{
+% \ea\ea\ea\sth@shadeenvname\ea\ea\ea}
+% \ea\sth@caption\ea}\ea[\sth@within]
+% (ignore the line breaks, which are for visual clarity only)
+% ... which resolves to ...
+% \ea \ea \ea \newtheorem \ea \ea \ea {
+% \ea \sth@shadeenvname \ea }
+% \sth@caption } [section ]
+% ... which in turn resolves to ...
+% \ea \newtheorem \ea {
+% \sth@shadeenvname }
+% Thm } [section ]
+% ... which, in its turn, resolves to ...
+% \newtheorem {
+% shadethm }
+% Thm } [section ]
+% which is the call that I want.
+% TeX is a strange place.
+
+\newcommand{\newshadetheorem}[1]{%
+\def\sth@envname{#1}\def\sth@shadeenvname{shade#1}%
+\sth@getcaption}
+
+\newcommand{\sth@getcaption}[2][\relax]{%
+\def\sth@caption{#2}\def\sth@numberedlike{#1}%
+\sth@getwithin}
+
+\newcommand{\sth@getwithin}[1][\relax]{%
+\def\sth@within{#1}%
+\if\sth@numberedlike\relax %if --numbered_like-- is not present
+ \if\sth@within\relax
+ %\newtheorem{shade\sth@envname}{\sth@caption}%
+ \expandafter\expandafter\expandafter\newtheorem\expandafter\expandafter\expandafter{\expandafter\sth@shadeenvname\expandafter}\expandafter{\sth@caption} %
+ \else
+ %\newtheorem{shade\sth@envname}{\sth@caption}[\sth@within]%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\newtheorem\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\sth@shadeenvname\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter{\expandafter\sth@caption\expandafter}\expandafter[\sth@within]%
+ \fi
+ \global\expandafter\countdef\csname \expandafter c\expandafter @\sth@envname\endcsname=\allocationnumber % just allocated shade<ctr>; make <ctr> be the same register
+ \expandafter\expandafter\expandafter\gdef\expandafter\csname the\sth@envname\expandafter\endcsname\expandafter{\csname theshade\sth@envname\endcsname}% make \the<ctr> display the same as \theshade<ctr>
+ \global\expandafter\let\csname p@\sth@envname\endcsname\@empty % and what the heck is p@<ctr>, anyway?
+\else %if --numbered_like-- is present
+ \if\sth@within\relax
+ %\newtheorem{shade\sth@envname}[\sth@numberedlike]{\sth@caption}%
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\newtheorem\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\sth@shadeenvname\expandafter\expandafter\expandafter}\expandafter\expandafter\expandafter[\expandafter\sth@numberedlike\expandafter]\expandafter{\sth@caption}%
+ \else
+ % Presumably get an error from newtheorem.
+ \typeout{!!!ERROR, shadethm.sty: \newshadetheorem used with both [numbered like] and [within] options.}
+ \newtheorem{\sth@shadeenvname}[\sth@numberedlike]{\sth@caption}[\sth@within]%
+ \fi
+\fi
+\expandafter\shade@@thm\expandafter{\sth@envname}}
+
+% \shade@@thm
+% arg1: name of environment (e.g., `definition')
+% Define an environment that will be called by the user (e.g.,
+% \begin{definition} .. \end{definition}.
+% Calls, e.g., \begin{shadedefinition} .. \end{shadedefinition} inside of
+% a \begin{shadebox} .. \end{shadebox} environment.
+\def\shade@@thm#1{%
+\newenvironment{#1}%
+{\begin{shadebox}\begin{shade#1}}%
+{\end{shade#1}\end{shadebox}}}
+
+\endinput %end shadethm.sty
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-shadetest.tex-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+\documentclass{article} % test of LaTeX package shadethm.sty
+\usepackage{shadethm}
+\newshadetheorem{theorem}{Theorem}[section]
+\newshadetheorem{cor}[theorem]{Corollary}
+\newtheorem{remark}[theorem]{Remark}
+\newtheorem{unshadedtheorem}[theorem]{Theorem}
+\newtheorem{comment}{Comment}[section]
+
+\begin{document}
+Document begins with some initial text.
+
+\section{First Section}
+Here is some initial text before the shaded box.
+
+\begin{theorem}
+This is the text to be shaded.
+\end{theorem}
+
+This is some text after the first shade.
+It is separated from the environments by a blank line; that is
+all handled as usual in \LaTeX.
+\begin{cor}
+This is more text to be shaded.
+It is numbered with the same counter as the environment above.
+
+Multiple paragraphs will be handled with the usual paragraph indentation,
+unless of course the user asks for a different paragraph indentation inside
+the environment.
+\end{cor}
+This is not separated from the prior environment by a blank line and
+so I don't expect a new paragraph.
+This shows that the default is for the shaded areas have the usual text size
+so that shading sticks out into the margin.
+This is the shadethm option \emph{bodymargin}.
+The behavior of having the shading end at the margin
+(so the words do not take up the full text width)
+comes from the option \emph{shademargin}, invoked with
+\verb!\usepackage[shademargin]{shadethm}!.
+
+
+\begin{unshadedtheorem}
+More text.
+This time not set in shade, but it is still numbered in the same sequence.
+\end{unshadedtheorem}
+
+A bit more.
+
+\begin{comment}
+More text.
+This time neither set in shade, nor numbered in the same sequence.
+\end{comment}
+
+
+\section{A New Section}
+
+Section preamble.
+
+\begin{theorem}
+This theorem is shaded and the number has been reset by the section.
+\end{theorem}
+
+\begin{remark}
+ And a closing remark
+\end{remark}
+Finishing text.
+
+\clearpage
+\section{A Test of Colors}
+This section shows how you can fool around to see some of you own colors.
+% Set up some lengths so that you can see the border.
+\setlength{\shadeboxsep}{2pt}
+\setlength{\shadeboxrule}{.4pt}
+\setlength{\shadedtextwidth}{\textwidth}
+\addtolength{\shadedtextwidth}{-2\shadeboxsep}
+\addtolength{\shadedtextwidth}{-2\shadeboxrule}
+\setlength{\shadeleftshift}{0pt}
+\setlength{\shaderightshift}{0pt}
+% Macro to test colors
+\newcommand{\thmwithcmykcolor}[2]{%
+\par Material before the theorem.
+\definecolor{shadethmcolor}{cmyk}{#1}%
+\definecolor{shaderulecolor}{cmyk}{#2}%
+\begin{theorem}
+This is a theorem set in the cmyk color \textbf{#1}, surrounded with a
+borderline set in the cmyk color \textbf{#2}.
+Note, for instance, that shades darken on overheads, so test your colors
+where you will use them.
+\end{theorem}}
+% Some colors
+\thmwithcmykcolor{.10,.10,0,0}{.75,.75,0,.5}
+\thmwithcmykcolor{.04,.04,0,.10}{.99,0,0.52,0.70}
+\thmwithcmykcolor{0,.13,.11,0}{0,0.88,0.85,0.35}
+The prior theorem illustrates what happens if you use the option
+\emph{colored}, as supplied in the file \verb!colored.sth!,
+except that the supplied file has the color stick out into the margin.
+
+One more supplied option is \emph{shadein} where each shaded theorem
+is indented, like a \LaTeX\ quotation.
+% ---> Uncomment if you want to test dvips's named colors
+% \newcommand{\thmwithnamedcolor}[1]{%
+% \par Material before the theorem.
+% \definecolor{shadethmcolor}{named}{#1}%
+% \definecolor{shaderulecolor}{named}{Black}%
+% \begin{theorem}
+% This is a theorem set in the named color \textbf{#1}, surrounded with a blac
+% borderline.
+% Note, for instance, that colors darken on overheads, so test your colors
+% where you will use them.
+% \end{theorem}}
+%
+% These are all the DVIPS named colors from color.pro (as of 1999-Aug-11).
+% \thmwithnamedcolor{GreenYellow}
+% \thmwithnamedcolor{Yellow}
+% \thmwithnamedcolor{Goldenrod}
+% \thmwithnamedcolor{Dandelion}
+% \thmwithnamedcolor{Apricot}
+% \thmwithnamedcolor{Peach}
+% \thmwithnamedcolor{Melon}
+% \thmwithnamedcolor{YellowOrange}
+% \thmwithnamedcolor{Orange}
+% \thmwithnamedcolor{BurntOrange}
+% \thmwithnamedcolor{Bittersweet}
+% \thmwithnamedcolor{RedOrange}
+% \thmwithnamedcolor{Mahogany}
+% \thmwithnamedcolor{Maroon}
+% \thmwithnamedcolor{BrickRed}
+% \thmwithnamedcolor{Red}
+% \thmwithnamedcolor{OrangeRed}
+% \thmwithnamedcolor{RubineRed}
+% \thmwithnamedcolor{WildStrawberry}
+% \thmwithnamedcolor{Salmon}
+% \thmwithnamedcolor{CarnationPink}
+% \thmwithnamedcolor{Magenta}
+% \thmwithnamedcolor{RedViolet}
+% \thmwithnamedcolor{Fuchsia}
+% \thmwithnamedcolor{Lavender}
+% \thmwithnamedcolor{Thistle}
+% \thmwithnamedcolor{Orchid}
+% \thmwithnamedcolor{DarkOrchid}
+% \thmwithnamedcolor{Purple}
+% \thmwithnamedcolor{Plum}
+% \thmwithnamedcolor{Violet}
+% \thmwithnamedcolor{RoyalPurple}
+% \thmwithnamedcolor{BlueViolet}
+% \thmwithnamedcolor{Periwinkle}
+% \thmwithnamedcolor{CadetBlue}
+% \thmwithnamedcolor{CornflowerBlue}
+% \thmwithnamedcolor{MidnightBlue}
+% \thmwithnamedcolor{NavyBlue}
+% \thmwithnamedcolor{RoyalBlue}
+% \thmwithnamedcolor{Blue}
+% \thmwithnamedcolor{Cerulean}
+% \thmwithnamedcolor{Cyan}
+% \thmwithnamedcolor{ProcessBlue}
+% \thmwithnamedcolor{SkyBlue}
+% \thmwithnamedcolor{Turquoise}
+% \thmwithnamedcolor{TealBlue}
+% \thmwithnamedcolor{Aquamarine}
+% \thmwithnamedcolor{BlueGreen}
+% \thmwithnamedcolor{Emerald}
+% \thmwithnamedcolor{JungleGreen}
+% \thmwithnamedcolor{SeaGreen}
+% \thmwithnamedcolor{Green}
+% \thmwithnamedcolor{ForestGreen}
+% \thmwithnamedcolor{PineGreen}
+% \thmwithnamedcolor{LimeGreen}
+% \thmwithnamedcolor{YellowGreen}
+% \thmwithnamedcolor{SpringGreen}
+% \thmwithnamedcolor{OliveGreen}
+% \thmwithnamedcolor{RawSienna}
+% \thmwithnamedcolor{Sepia}
+% \thmwithnamedcolor{Brown}
+% \thmwithnamedcolor{Gray}
+
+Enjoy!
+\textit{--Jim Hefferon}
+\end{document}
+
+
+
+
+
+