[dev-context] Enhancements to core-des for theorems

Aditya Mahajan adityam at umich.edu
Fri Jun 1 07:58:15 CEST 2007

Hi Hans,

I am attaching my enhancements for core-des. This takes care of most 
of the needs for theorems with ConTeXt. I hope that I have not broken 
anything. I have tested this with a 40 page documents, while Oliver, 
Olaf, and Dalyoung have tested this with bigger documents. The test 
files show different features.

It takes care of a few bugs in enumerations, (and introduces new 
ones... there is a suprious space somewhere which I can not find)
Basically, more enhanced support for titles, and end of proof markers, 
and makes sure that conversion=whatever works correctly.

If you want a "title" for the theorem, say


titledistance, titlestyle, titlecolor, titleleft, and titleright 
control the appearance of the title. To use a title, say


both the label and the title are optional, so you can have

\starttheorem[label] This is a theorem with no title \stoptheorem


\starttheorem {title} this is a theorem with no label \stoptheorem

\starttheorem this is a theorem with neither a title nor a label 

For end of proof markers, say

\definetheorem[theorem][endmarker=\math{\square}] or whatever symbol 
you want.

Then a end of proof marker with will be placed at the \stoptheorem. 
Sometimes, for example after an itemize, the end of thoerem marker may 
appear on a line of its own. Then say \placenedmarker just before 

To couple two enumerations


To couple just the numbers


I cannot use number=theorem because number=yes|no is to enable disable 
numbering. Maybe a better choice will be numbering=yes|no, and 
number=counter. But that will break backward compatibility :(

The main thing that needs to be done is to get end of proof markers to 
work with formulas, but that is a bit difficult, so I have left it for 
the future.


-------------- next part --------------
%%\message{<Paul Taylor's right-justified end-of-proof mark, 11 June 2003>}
%% Lines commented by Aditya Mahajan start with two %%
%% \ProvidesPackage{QED}[2003/06/11 right-justified end-of-proof mark]%
%\ProvidesFile{QED.sty}% I don't understand what this is for
%*                                                                      *%
%*      Maybe you already have a \qed macro to put a little square      *%
%*      on the right hand side at the end of a mathematical proof?      *%
%*                                                                      *%
%*                      IT'S PROBABLY MINE!                             *%
%*                                                                      *%
%*           Please compare yours with \parag at pushright below.          *%
%*                                                                      *%
%*      This new file is compatible, it fixes the bugs, has extra       *%
%*      features, and is maintained and portable.  Please use it!       *%
%*                                                                      *%
%*      NEW FEATURE \WillHandleQED and \HandleQED for environments      *%
%*      which do not give access to the right hand side of the page.    *%
%*                                                                      *%
%*      Now also available: \DefineStandardTheorems or                  *%
%*      \usepackage[define-standard-theorems]{QED}                      *%
%*                                                                      *%

% COPYRIGHT (C) 1993-2003 Paul Taylor.

% You may use this file for any purpose. You may copy it on condition that
% you do so in exactly the form in which it was supplied, make no charge
% for the copy and impose the same conditions on the recipient.

% This software is supplied ``as is'' without warranty, express or implied,
% including but not limited to merchantability and fitness for any particular
% purpose. No liability is accepted by the author, Queen Mary and Westfield
% College, Imperial College or any third party for any direct or consequential
% damages, however caused.
% In all cases you must keep several backup versions of your files in a place
% to which your machine cannot write, and you must check documents visually
% before submitting the final version to a publisher or expensive printer.

% WARNING: If you use this with Frank Mittlebach's "theorem.sty" you
% MUST load theorem first, then QED, then do the \newtheorem commands.

%       Authoritative version:  /pub/tex/contrib/pt/proofs/QED.sty
%       by anonymous FTP from:  ftp.dcs.qmw.ac.uk
%       also CTAN:              macros/generic/proofs/taylor/QED.sty
%       author/maintained by:   Dr Paul Taylor <pt at di.unito.it>

% ! You can't use `\unskip' in vertical mode.
% from isolated \qed (ie as paragraph on its own)



% LaTeX2e \usepackage options: see \DeclareOption commands below
% theorems-as-commands roman-theorems italic-theorems
% auto-QED explicit-QED number-theorems dont-number-theorems
% black-square open-square

%       \begin{Proof} ... \end{Proof}
%       or    \Proof  ... \endProof
%       or    \Proof  ... \endproof
%       or    \Proof  ... \qed          also \QED \QEF and \QEI

% WARNING: \qed which doesn't follow \Proof will not print the square.

% Each properly nested Proof/endProof pair gets a single
% \qedsymbol at the end, on the far right hand side.
% Unfortunately, this may still be in the wrong place
% if the proof ends with a display or itemisation.
% To solve this, \qed may be put *inside* the last substantive
% environment; the \qedsymbol will be put at that point
% (the visual end) and suppressed at the logical end of proof.

% Examples:
%       \begin{Proof}                   \begin{Proof}
%         ...                             ...
%         \begin{eqnarray}                \begin{itemize}
%          ... &=& ... \\                   \item ...
%          ..  &=& ... &\qed                \item ...   \qed
%         \end{eqnarray}                  \end{itemize}
%       \end{Proof}                     \end{Proof}
% also works with $$...$$ and \[...\] displays, including fleqn.sty.

% Unfortunately some environments, such as picture, do not allow this at all.
% See the section "centering environments" below for the mechanism for
% passing \qed to such an environment for special processing.

% In fact \qed will only work in those environments which provide access to
% the right hand side of the page. In other words, wherever you think
% "\hfill\square" ought to work then \qed will; of course it is just because
% that naive method doesn't work that this macro file is needed at all.
% The macro was designed to solve the problem in the case of "unrestricted
% horizontal mode" (ie at the end of a paragraph); it also works in $$
% displays by pretending to be an equation number. In most other cases it
% basically does "\hfill\square" or "\hfill$\square$" and hopes for the best.

% If you have to put \qed outside the environment, it may be appropriate to
% put \vskip-\baselineskip before it, unless of course this would over-print.
% There is, however, still a danger that TeX will break the page here.
% This seems to be unavoidable if the environment ends with a \penalty.

% The eqnarray example above does not in fact work: if you try it you'll
% get "! Paragraph ended before \llap was complete" with LaTeX in a mess.
% This is a very common place where you might want to put the end of proof
% mark, and I also consider that the fourth column should be available for
% "reasons" for equational steps.  The following substitute for \eqnarray
% allows this, whilst being compatible with automatic numbering. I have
% proposed it to Rainer Sch\"opf for inclusion in LaTeX. If you want to
% use it, please copy it to another file rather than uncommenting it here.
% Don't forget to use \makeatletter or put it in a documentstyle (.sty) file.
% \def\eqnarray{\stepcounter{equation}\let\@currentlabel\theequation
% \global\@eqnswtrue\m at th\global\@eqcnt\z@\tabskip\@centering\let\\\@eqncr
% $$\halign to\displaywidth\bgroup\@eqnsel\hskip\@centering$\displaystyle
% \tabskip\z@{##}$&\global\@eqcnt\@ne\hskip 2\arraycolsep \hfil${##}$\hfil
% &\global\@eqcnt\tw@\hskip2\arraycolsep$\displaystyle\tabskip\z@{##}$\hfil
% \tabskip\@centering&%
%       \global\@eqcnt\thr@@\hbox to\z@\bgroup\hss##%*** instead of "\llap{##}"
% \tabskip\z@\cr}%
% \def\@@eqncr{\let\@tempa\relax
% \ifcase\@eqcnt \def\@tempa{& & &}\or \def\@tempa{& &}%
%       \or\def\@tempa{&}\else\@eqnswfalse%*** instead of "\else\def\@tempa{&}"
% \fi\@tempa\if at eqnsw\@eqnnum\stepcounter{equation}\fi
%       \egroup%*** added, to match \bgroup in fourth cell of preamble
% \global\@eqnswtrue\global\@eqcnt\z@\cr}

% Why can't we do all of this with \endProof? Because by that stage
% the damage has been done: the environments, paragraphs or
% displays have already been closed and their \hbox'es added
% to the current vertical list, and cannot be removed for
% alteration if this is the current page.

% Even if you don't need to put \qed inside an inner environment
% to avoid a blank line, it's still a good idea to do so, because
% otherwise it's possible that intervening end-of-environment
% material may allow TeX to put the mark on the next page.

% This file may be called QED.sty, QED.tex, qed.sty or qed.tex.
% It may be loaded using \input, \usepackage or as a \documentstyle option,
% as it is careful to handle the \catcode of @ appropriately.

% If you don't use theorem.sty, this file instead provides options to use
% commands to begin theorems, instead of enclosing them in environments,
% and to suppress numbering and italicisation. A rudimentary version of
% \newtheorem for plain TeX is also implemented (always using commands
% rather than environments).

% At the end of the file some useful \newtheorem
% commands are listed but not executed.

% NB \Theorem\Proof\endProof\qed will print the second square, whereas
% \begin{Theorem}\end{Theorem}\begin{Proof}\end{Proof}\qed will not.

% Make @ letter, saving its old code to restore at the end of this file.
% Look for this towards the end of the file if you think something's missing!
% "plain.tex" defines \lq as a synonym for back quote (character constant);
% I use it to avoid corruption when sending TeX files by email via BITNET.
% \edef\qedrestoreat{\noexpand\catcode\lq\noexpand\@=\the\catcode\lq\@}%%
% \catcode\lq\@=11

% in LaTeX, \protect the user commands;
% in plain TeX, ensure that it is defined.
% \ifx\protect\undefined\let\protect\relax\fi


%                               OPTIONS

% These are the user commands.


%% \def\qed{\protect\@qed{$\qedsymbol$}}% suppressible printing of \qedsymbol
%% % \pushright takes an argument, which it always prints
%% % it is (re)defined by \WillHandleQED and \UnHandleQED below (12.4.94)
%% % theoremata in Euclid needed proof:    "which   was  to be shown"
%% \def\QED{\protect\@qed{{\rm Q.E.D.}}}%  "quod   erat  demonstrandum"
%% % but problemata needed construction:   "which   was  to be found"
%% \def\QEI{\protect\@qed{{\rm Q.E.I.}}}%  "quod   erat  inveniendum"
%% % alternatively:                        "which   was  to be done/made"
%% \def\QEF{\protect\@qed{{\rm Q.E.F.}}}%  "quod   erat  faciendum"
%% % a LaTeX environment
%% \def\Proof{\protect\@Proof}\def\endProof{\protect\@endProof}%
%% \let\proof\Proof\let\endproof\endProof
%% % These are the user-settable parameters.
%% % The actual (maths) symbol used by \qed
%% \def\qedsymbol{\square}% PLEASE NOTE: this is in the AMS symbols font.
%% %\def\qedsymbol{\blacksquare}%  use one of these instead
%% %\def\qedsymbol{\hbox{\rm Q.E.D.}}%        if you prefer
%% %\def\qedsymbol{\dashv}% this is what the Journal of Symbolc Logic likes.
%% % This is the text used by \Proof.
%% % A new paragraph is begun without indentation.
%% % Change it to {\kern\parindent\sc D\'emonstration: } if you like.
%% \def\TheWordProof{\bf Proof\enskip}
%% % This is the font command used for the text of proofs
%% \def\ProofFont{}
%% % The command \AutoQEDtrue causes a \qed in \end{Theorem}, so you do
%% %       \begin{Theorem} ... \begin{Proof} ... \end{Proof} \end{Theorem}
%% % but if you omit the proof, the statement gets a little square at the end.
%% \newif\ifAutoQED\AutoQEDfalse
%% % The remaining options are redundant with theorem.sty
%% % so are not defined if this has been loaded.
%% \newif\ifNumberResults
%% \ifx\theorem at style\undefined
%%    %
%%    % How to print the name (#1), number (#2) and attribution (#3) of a theorem.
%%    \NumberResultstrue
%%    % If the number (#2) is absent, "\unskip" removes the
%%    % unwanted space "\ " from before it (16 Feb 1993).
%%    \def\TheoremHeader#1#2#3{\bf #1\ifNumberResults\ #2\unskip\fi#3}
%%    %
%%    % This is the font command used for the text of theorem enunciations
%%    % change to {\rm} or {\small} if you like.
%%    \def\TheoremFont{\it}
%%    %
%%    % The command \NumberResultsfalse will suppress theorem numbering.
%%    %
%%    % The command \TheoremsAsCommands will allow you to write
%%    % \Theorem instead of \begin{Theorem} ... \end{Theorem}.
%%    % In this case italicisation is suppressed by default.
%%    % To do this with theorem.sty would involve rewriting the substyles.
%%    %
%%    % WARNING: if you subsequently redefine \TheoremFont, and use the command
%%    % instead of the environment, the font will remain in force afterwards!
%% \fi
%% % The document style option "theorems-as-commands" will allow you to
%% % write \Theorem instead of \begin{Theorem} ... \end{Theorem}.
%% % Moved here from further down. 10 Jan 1994
%% \def\TheoremsAsCommands{%
%%   \def\TheoremFont{}% suppress italicised theorems.
%%   \def\begin at theorem##1{%
%%      \thmbreak
%%      \save at set@qed % enable \qed
%%      \noindent{##1}% the name
%%      %\TheoremFont % italicise at your own risk!
%%    }%
%%   %\def\thmbreak{\par\removelastskip\smallskip}%
%%   \def\thmbreak{\par\bigskip}%
%%   \def\@endtheorem{\ifAutoQED\qed\fi\restore at qed}%
%% }%
%% %\expandafter\let\csname ds at theorems-as-commands\endcsname\TheoremsAsCommands
%  If you already have a macro called \qed, \endproof or \pushright
%  which is laid out in a similar way to the following two definitions
%  (but with \hbox at pushright incorporated) then it is almost certainly
%  my code, which has been copied anonymously via numerous people since
%  my Cambridge PhD thesis in August 1986. Belated acknowledgements to
%  Chris Thompson of the Cambridge University Computing Service for his
%  help with my early attempts at TeX, in particular this problem.

%  The complexity of the macro necessary to get a little box on the
%  right-hand-side at the end of a proof is amazing.  It really does
%  have to be this long!  Otherwise you're liable to get it at the
%  beginning of the next line, or even on the next page. 

\def\parag at pushright#1{{% set up
    \parfillskip=0pt            % so \par doesnt push \square to left
    \widowpenalty=10000         % so we dont break the page before \square
    \displaywidowpenalty=10000  % ditto
    \finalhyphendemerits=0      % TeXbook exercise 14.32
    %                   horizontal
    %\leavevmode                % not needed since we now only use it in hmode
    \hbox at pushright             % this used to be incorporated
    #1%                         % the end-of-proof mark (or whatever)
    %                     vertical
    \par}}%                     % build paragraph with the above parameters

\def\hbox at pushright{% horizontal
    \unskip                     % remove previous space or glue
    \nobreak                    % don't break lines
    \hfil                       % ragged right if we spill over
    \penalty50                  % discouragement to do so
    \hskip.2em                  % ensure some space
    \null                       % anchor the following \hfill
    \hfill                      % push \square to right

% Ideally \endProof should do all this. We should be able to add the symbol
% to the last line after the paragraph, display or whatever other structure
% has been completed and we've returned to vertical mode. This isn't possible
% on the current page (outer vmode) because \lastbox doesn't work there.

% But \ifinner is true inside a \vbox, \vadjust or \insert (LaTeX \parbox,
% minipage, figure or table), and in these circumstances we can use \lastbox.
% We would have to strip & restore glue & penalties (\insert, \mark and \write
% are obstacles to this) to get access to the last line (box), which may
% still not have the correct baseline. We could check its natural width
% against the page width, but if we re-set it, centering and (right)
% justification might be disturbed. Is this worth the trouble?
\def\vbox at pushright#1{\expandafter\message %  (2 Jan 1994)
  {QED.sty could be improved in this case (line \the\inputlineno): please ask}%
  \page at pushright{#1}}%

% Using this method the Proof environment could be implemented by collecting
% the entire proof in its own \vbox, modifying that and \unvbox'ing it to the
% current page. This approach may lead to the following problems:
%   (i) footnotes, floats, marginpars, labels and index items may be lost;
%  (ii) overflow of TeX's main memory, especially if \end{Proof} is missing;
% (iii) I don't know how page-breaking would be handled.


% Switch to enable/suppress \qedsymbol; since suppression may be done
% within a nested scope it must be global, so we do our own save/restore
% in a symbol which is local to the Proof environment.

%% \newif\if at qed\@qedfalse
%% \def\save at set@qed{\let\saved at ifqed\if at qed\global\@qedtrue}%
%% \def\restore at qed{\global\let\if at qed\saved at ifqed}
%% % prefer proofs with statements if possible - hence \penalty700
%% % the only essential part of this is \save at set@qed
%% \def\@Proof{%
%%    \par\removelastskip\smallskip\penalty700
%%    \save at set@qed
%%    \noindent\ProofFont{\TheWordProof\enskip}%
%% }%
%% \def\@endProof{%
%%    \qed\restore at qed
%%    \penalty-700 \smallskip
%% }
%% \def\@qed#1{\check at pt@fm at thm
%% \if at qed                                 % have we already done \qed?
%%      \global\@qedfalse\pushright{#1}%  - no  - do it now, but not again
%% \else\ifhmode\ifinner\else\par\fi\fi%  - yes - just end paragraph, if any
%% \fi}

% \pushright{text} always prints its argument, on the far right, in text mode
       \ifinner\vbox at pushright{#1}% vertical mode (see comments above)
       \else   \page at pushright{#1}%
  \else\ifmmode\maths at pushright{\hbox{#1}}% maths (force a text argument)
       \else\ifinner\hbox at pushright{#1}%  inside an \hbox
            \else\parag at pushright{#1}%    in a paragraph
  \fi  \fi  \fi
}% (22 Feb 1993) removed extra {} which would destroy our \] below

% In the \hbox and maths cases we are really at the mercy of the environment.
% Assuming that we have $\qed$ simply embedded in a paragraph, the horizontal
% processing by \hbox at pushright will at least make sure that the square isn't
% at the beginning of the line, but we can't stop it being on the next page.
% However it is more likely that the reason why we're in maths mode is that
% we're inside an eqnarray or similar, in which case \hfill will do its best
% to put the square on the right of the available space. (See \vadjust below.)
\def\maths at pushright#1{%
     \hbox at pushright{#1}%
     \eqno#1%   use TeX's right equation number feature (\eqno) within $$.
     \def\]{$$\ignorespaces}%    suppress LaTeX's error checking (HACK!)
}% (22 Feb 1993) removed extra {} which would destroy our \] above

% outer vertical mode (the current page)
% There's very little we can do in these circumstances!
% Penalties still allow the page to be broken.
% If the user has put negative glue in, leave it alone. (15 Feb 1994)
\def\page at pushright#1{% 18 Jan 1994
  %\unpenalty % ineffective
%%  \ifdim\skip@>\z@
%%        \unskip    % remove \parskip, but only (15 Feb 1994) if it's positive
%%                   % This causes and error (AM)
%%  \else\skip@\z@\relax
%%  \fi
  %\unpenalty % TeX won't let me do this
  \advance\dimen at -\prevdepth            % save \prevdepth to make a strut
  \nobreak                              % don't break the page here
  \hbox to\hsize{%
    \ifdim\dimen@>\z@\ht\z@\dimen@\fi   % simulate \baselineskip
%%  \vskip\skip@                  % replace old \parskip

% An idea that didn't work: see TeXbook p188. (16 Feb 1993)
% Use \predisplaysize to find out the width of the previous box,
% in the case where it has already been completed.
% But this can only be used inside displays ($$), and a display in
% vertical mode begins a paragraph first, so we end up with
% \predisplaysize=\parindent+2em whatever happened in the previous
% paragraph.

% Another idea: it may be worth trying \vadjust, if only to insert \nobreak.
% The problem with this is that if we are too deeply nested in horizontal
% or maths lists, the adjustment may not be able to find its way out to the
% enclosing vertical list. In the case of array-like environments, it will
% appear (assuming it manages to get out) after the current row of the array.

% We have to add to the theorem environments the commands to enable \qed.
% This is done by re-defining \@thm#1#2.
% Note that Mittelbach's theorem.sty re-defines \@thm and \@endtheorem, so
% that must be loaded before us, otherwise our changes will get over-written
% and \qed will never be enabled.
% Paul.sty didn't use this method of gaining control inside a theorem,
% whereas it did define \qed and \pushright, so here is the one place
% where we can check for it.

%% \ifx\nonqed at thm\undefined % otherwise double loading causes a loop 22 Feb 1993
%%    \let\nonqed at thm\@thm % save original
%%    \let\nonqed at endthm\@endtheorem
%% \fi
%% \def\@thm{\save at set@qed\nonqed at thm}%
%% \def\@endtheorem{\ifAutoQED\qed\fi\restore at qed\nonqed at endthm}%

% those which don't give their contents access to the right hand side
% of the page, such as center, picture, ...  (12 April 1994)

% Each individual environment (both the standard ones and those defined
% by the user) needs to co-operate in order to make \qed and \pushright work.
% It is not the business of this package to rewrite LaTeX in this way,
% but the following mechanism may be inserted in to other environments.
%  - put \WillHandleQED in the \begin part of the environment definition;
%    then if a \qed occurs in the body of the environment it is stored
%    in \QEDbox until...
%  - \HandleQED anywhere in the \end part of the environment definition
%    (even inside dollars, braces or another environment) prints it.
% For example:
% \newenvironment{qedpicture}%
%    {\begin{picture}\WillHandleQED}%
%    {\put(0,0){\HandleQED}\end{picture}}
% To make this compatible with *not* loading QED.sty,
% add the following to macro files which use \WillHandleQED and \HandleQED:
%   \ifx\WillHandleQED\undefined
%      \let\WillHandleQED\relax
%      \let\HandleQED\relax
%      \let\UnHandleQED\relax % if you use it
%      \let\QEDbox\voidb at x    % must have \makeatletter here!
%   \fi
% \UnHandleQED restores normal processing; this may be useful for
% the minipage environment, which has its own notion of "right hand side"
% of the page.
% The width of the saved \qed is available for testing as \wd\QEDbox

%% \newbox\qed at box % the box in which to save \qed for special handling
%% \def\WillHandleQED{\relax
%% \ifx\HandleQED\nohandle at qed
%%    % no enclosing environment has declared \WillHandleQED
%%    \def\pushright{\global\setbox\qed at box\hbox}% \qed will be saved
%%    \let\QEDbox\qed at box % point at the right box
%%    \def\HandleQED{\unhbox\QEDbox}% print it
%%    \aftergroup\check at handle@qed  % check that this really gets done
%% \else
%%    % an enclosing environment already wants to catch \qed
%%    % \HandleQED doesn't print anything - let the saved \qed pass through
%%    \let\QEDbox\voidb at x % by pointing at an empty box
%% \fi}
%% \def\nohandle at qed{%
%% \errhelp{One of them is missing: see QED.sty.}%
%% \errmessage{This environment uses \string\WillHandleQED\space and
%% \string\HandleQED\space incorrectly}}
%% \def\check at handle@qed{\relax
%% \ifvoid\qed at box\else\expandafter\nohandle at qed\fi}
%% \def\UnHandleQED{%
%% \let\HandleQED\nohandle at qed
%% \let\QEDbox\voidb at x
%% \def\pushright{\protect\@pushright}}%
%% \UnHandleQED
%% %===========================================================================
%% % If theorem.sty hasn't been loaded, arrange to check it again in \@qed.
%% % And check (then) whether you've actually defined \square.
%% % changed 2 June 1993: don't define it now, as that would confuse amssymb.sty
%% \ifx\theorem at style\undefined
%%    \def\check at pt@fm at thm{\relax
%%      \ifx\square\undefined
%%        \gdef\square{\bigcirc
%%           \errhelp={Anonymous ftp e-math.ams.com /ams/amsfonts}%
%%           \errmessage{\string\square\space is an AMS symbol}%
%%           \global\let\square\bigcirc}%
%%      \fi
%%       \ifx\theorem at style\undefined
%%           \global\let\check at pt@fm at thm\relax
%%       \else\errhelp={The macros \@thm and \@endtheorem need to be re-defined.}%
%%           \errmessage{QED.sty must be loaded AFTER theorem.sty but before
%%            using \string\newtheorem}%
%%       \fi
%%       \global\let\check at pt@fm at thm\relax
%%       }%
%% \else
%%    \def\check at pt@fm at thm{%
%%       \ifx\square\undefined
%%          \def\square{\bigcirc
%%          \errhelp={Anonymous ftp e-math.ams.com /ams/amsfonts}%
%%          \errmessage{\string\square\space is an AMS symbol}%
%%          \global\let\square\bigcirc}%
%%       \fi
%%       \global\let\check at pt@fm at thm\relax
%%       }%
%% \fi
%% %===========================================================================
%% \def\goalbreak#1{% break unless there's #1 left on the page
%%    \par\removelastskip
%%    \dimen0\pagegoal\advance\dimen0-\pagetotal
%%    \ifdim\dimen0>0pt
%%       \ifdim\dimen0<#1\relax
%%           \newpage
%%    \fi\fi
%%   }
%% \def\allowlines#1{\goalbreak{#1\baselineskip}}
%% %===========================================================================
%% % Define some standard ``theorem'' types.
%% \def\DefineStandardTheorems{%
%% %
%% % First set up uniform numbering in LaTeX;
%% % don't use this in plain TeX because this usage of \newcommand is not
%% % supported and we have already done by hand what it would do in LaTeX,
%% % viz to define the macro \theResult and the count \c at Result.
%% \relax\ifx\@@thm\undefined
%%         \newtheorem{Result}{Result}[subsection]%
%%         \@addtoreset{Result}{section}%
%%         \ifx\chapter\undefined\else\@addtoreset{Result}{chapter}\fi
%% \fi
%% %
%% \let\theUnnumbered\relax\countdef\c at Unnumbered255 \def\p at Unnumbered{}%
%% %
%% \def\mkthm##1{\newtheorem{##1}[Result]{##1}}%
%% %
%% \mkthm{Answer}
%% \mkthm{Answers}
%% \mkthm{Axiom}
%% \mkthm{Axioms}%
%% \mkthm{Assumption}%
%% \mkthm{Assumptions}%
%% \mkthm{Conjecture}%
%% \mkthm{Conjectures}%
%% \mkthm{Construction}%
%% \mkthm{Constructions}%
%% \mkthm{Convention}%
%% \mkthm{Conventions}%
%% \mkthm{Corollary}%
%% \mkthm{Corollaries}%
%% \mkthm{Counterexample}%
%% \mkthm{Counterexamples}%
%% \mkthm{Definition}%
%% \mkthm{Definitions}%
%% \mkthm{Example}%
%% \mkthm{Examples}%
%% \mkthm{Exercise}%
%% \mkthm{Exercises}%
%% \mkthm{Fact}%
%% \mkthm{Facts}%
%% \mkthm{Lemma}%
%% \mkthm{Lemmas}%
%% \mkthm{Lemmata}%
%% \mkthm{NB}%
%% \mkthm{Notation}%
%% \mkthm{Notations}%
%% \mkthm{Note}%
%% \mkthm{Observation}%
%% \mkthm{Observations}%
%% \mkthm{Problem}%
%% \mkthm{Problems}%
%% \mkthm{Proposition}%
%% \mkthm{Propositions}%
%% \mkthm{PS}%
%% \mkthm{Remark}%
%% \mkthm{Remarks}%
%% \mkthm{Question}%
%% \mkthm{Questions}%
%% \mkthm{Theorem}%
%% \mkthm{Theorems}%
%% \mkthm{Thesis}%
%% \mkthm{Theses}%
%% \mkthm{Warning}%
%% \mkthm{Warnings}%
%% }
%% %===========================================================================
%% % Interaction with LaTeX2e (2 Jan 1994)
%% % \DeclareOption{roman-theorems}{\def\TheoremFont{\rm}}%
%% % \DeclareOption{italic-theorems}{\def\TheoremFont{\it}}%
%% % \DeclareOption{theorems-as-commands}{\TheoremsAsCommands}%
%% % \DeclareOption{auto-QED}{\AutoQEDtrue}%
%% % \DeclareOption{explicit-QED}{\AutoQEDfalse}%
%% % \DeclareOption{number-theorems}{\NumberResultstrue}%
%% % \DeclareOption{dont-number-theorems}{\NumberResultsfalse}%
%% % \DeclareOption{black-square}{\def\qedsymbol{\blacksquare}}%
%% % \DeclareOption{open-square}{\def\qedsymbol{\square}}%
%% % \DeclareOption{define-standard-theorems}{\DefineStandardTheorems}%
%% %===========================================================================
%% % If Mittelbach's theorem.sty is loaded, skip the rest of the file.
%% \ifx\theorem at style\undefined\else
%%     \ProcessOptions
%%     \qedrestoreat
%%     \expandafter\endinput
%% \fi
%% %===========================================================================
%% % Allow the user to suppress italicisation and numbering.
%% % The following two macros are called by LaTeX to begin a theorem
%% % respectively with and without an optional (``attribution'') argument.
%% % It is clear from latex.tex that they are intended to be customised.
%% % The code common to the two has been taken out as \begin at theorem and
%% % \TheoremHeader. Of these, the former is re-defined by \TheoremsAsCommands.
%% \def\@opargbegintheorem#1#2#3{\begin at theorem{\TheoremHeader{#1}{#2}{ (#3)} }}
%% \def\@begintheorem#1#2{\begin at theorem{\TheoremHeader{#1}{#2}{} }}
%% \def\begin at theorem#1{%
%%   \trivlist\item[\hskip\labelsep {#1}]%         % LaTeX likes this method.
%%   \TheoremFont                                  % Italicise the enunciation
%%   \ifx\ProofFont\empty\def\ProofFont{\rm}\fi    % but not any nested proof.
%%   }%
%% %%% Here's what LaTeX (92/1/14) does:
%% %%%% RmS 91/08/14 Moved \it after \item to make it work with NFSS
%% %%\def\@begintheorem#1#2{\trivlist \item[\hskip \labelsep{\bf #1\ #2}]\it}
%% %%\def\@opargbegintheorem#1#2#3{\trivlist
%% %%      \item[\hskip \labelsep{\bf #1\ #2\ (#3)}]\it}
%% %%\def\@endtheorem{\endtrivlist}
%% %===========================================================================
%% % If we're running under LaTeX, skip the rest of the file.
%% \ifx\newtheorem\undefined\else
%%    \ProcessOptions
%%    \qedrestoreat
%%    \expandafter\endinput
%% \fi
%% %===========================================================================
%% % This implements a rudimentary version of \newtheorem for plain TeX.
%% % Only the unattributed theorems and the
%% % declarations \newtheorem{Theorem}[Result]{Theorem} and
%% % \newtheorem{Convention}[Unnumbered]{Convention} are supported.
%% % The numbering is based on the counts \chapternumber, \sectionnumber
%% % and \subsectionnumber, which it is up to you to define with \newcount.
%% % It's also up to you to reset \c at Result at the beginning of each section.
%% % Form the number: (chapter).(section).(subsection).(#1)
%% % where any of the first three parts which is zero
%% % negative or undefined is omitted.
%% \def\ther at sult#1{%
%% \ifx\chapternumber\undefined\else
%%    \ifnum\chapternumber>0 \number\chapternumber.\fi\fi
%% \ifx\sectionnumber\undefined\else
%%    \ifnum\sectionnumber>0 \number\sectionnumber.\fi\fi
%% \ifx\subsectionnumber\undefined\else
%%    \ifnum\subsectionnumber>0 \number\subsectionnumber.\fi\fi
%% \expandafter\number\csname c@#1\endcsname}%
%% % plain version of LaTeX's \@thm
%% \def\plain at thm#1#2{% #1=counter, #2=text
%%   \save at set@qed
%%   \expandafter\advance\csname c@#1\endcsname1
%%   \@begintheorem{#2}{\csname the#1\endcsname}%
%% }%
%% % Rudimentary \newtheorem
%% \def\newtheorem#1[#2]#3{%   #1=command, #2=counter, #3=text
%%   %
%%   % \def\#1{\plain at thm{#2}{#3}}
%%   \expandafter\def\csname #1\endcsname{\plain at thm{#2}{#3}}%
%%   %
%%   % \def\end#1{\@endtheorem}
%%   \expandafter\def\csname end#1\endcsname{\@endtheorem}%
%%   %
%%   % if \c@#2 is not defined
%%   %    \newcount\c@#2
%%   %    \def\the#2{\ther at sult{#2}}
%%   \expandafter\ifx\csname c@#2\endcsname\relax
%%      \expandafter\expandafter\csname newcount\endcsname
%%         \csname c@#2\endcsname
%%      \expandafter\def\csname the#2\endcsname{\ther at sult{#2}}%
%%   \fi
%% }%
%% \TheoremsAsCommands
%% \qedrestoreat\endinput
%% %===========================================================================
%% % BUGS
%% % \item\qed\end{letterlist} puts the square above the item label.
%% % ! You can't use `\unskip' in vertical mode.
%% % from \qed in a paragraph on its own.

-------------- next part --------------
% Testing for http://archive.contextgarden.net/message/20061127.085140.3740ad43.en.html
% There seems to be a spurious space after remark, I can not pin point why it
% is coming, if I end all lines with % it goes away. Maybe someone can see the
% offending line more easily.

\input core-des

\defineenumeration    [theorem] [text=Theorem] 
\defineenumeration    [remark] [text=Remark] 

\setupenumerations    [location=serried,width=fit,distance=0pt,stopper=.] 
\setupenumerations    [remark] [number=no] 


\input ward 

\input tufte 


-------------- next part --------------
% This is the first test, title working.

\input core-des

\setupformulas[numberstyle=normal] % This should probably be the default

  [        title=yes,

\defineenumeration [problem]    [text=Problem]
\defineenumeration [definition] [text=Definition]
\defineenumeration [theorem]    [text=Theorem]
\defineenumeration [lemma]      [text=Lemma]

  [      text=Proof,


\startproblem[prob:basic] {Finite Horizon Real||Time Communication Problem}
  Assume that the encoder and the receiver know the source statistics
  $P_{X_1}$ and $P_{X_{t+1} \mid X_t}$, $t=1,\dots,T$, the forward and
  backward channel functions $ H =  h$, $\tilde H = {\tilde h}$, the forward
  and the backward channel noise statistics $P_N$ and $P_{\tilde N}$, the
  distortion functions $\rho_t(\cdot)$, $t=1,\dots,T$ and the time horizon
  $T$. Choose a design $(C,G,L)$ that is optimal with respect to
  performance criterion of~(10), i.e.,
    J_T(C,G,L) = J_T =
    \min_{ \startsubstack
             \NC C \in  C^T \NR
             \NC G \in  G^T \NR
             \NC L \in  L^T \NR
  where $ C^T =  C_1 \times \cdots \times  C_T$, $
  C_t$ is the family of functions from $ X^t \times \tilde { Y}
  \to  Z$, $ G^T =  G \times \dots  G$
  ($T$||times), $ G$ is the family of functions from $ Y \times
   M \to \hat { X}$, $ L^T =  L \times \dots
   L$ ($T$||times), and $ L$ is the family of functions from
  $ Y \times  M \to  M$.

    \item Consider a component of $\bar B_t$:
      \input tufte
    \item Consider a component of $\dot B_t$:
      \input tufte
    \item Consider a component of $\hat B_t$: 
      \input tufte

\input knuth


-------------- next part --------------
% To see if multi theorems can have the same number.

\input core-des

% use number is the key


\starttheorem {First Theorem}
  \input zapf

\startdefinition {Test Title} %This should not be bold.
  \input knuth

\starttheorem {Second Theorem}
  \input zapf

-------------- next part --------------
% Sharing all features

\input core-des



\starttheorem {First Theorem}
  \input zapf

\startdefinition {Test Title}
  \input knuth

\starttheorem {Second Theorem}
  \input zapf

-------------- next part --------------
% conversion=whatever works with enumerations now.

\input core-des

\defineenumeration [theorem]    [text=Theorem,conversion=Character]


\input knuth

-------------- next part --------------
A non-text attachment was scrubbed...
Name: core-des.tex
Type: application/octet-stream
Size: 32354 bytes
Url : http://www.ntg.nl/mailman/private/dev-context/attachments/20070601/e2525ede/attachment-0001.obj 
-------------- next part --------------
% If you do not want to show titles

\input core-des

\defineenumeration [theorem]    [text=Theorem, titlecommand=\gobbleoneargument]


\starttheorem {Whatever}
  \input tufte


More information about the dev-context mailing list