Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fractional theorem numbers; see #601 #613

Open
wants to merge 2 commits into from

3 participants

@mikeshulman
Owner

No description provided.

@andrejbauer andrejbauer commented on the diff
introduction.tex
@@ -494,8 +494,12 @@ \subsection*{How to read this book}
Finally, recall that this book was written as a massively collaborative effort by a large number of people.
We have done our best to achieve consistency in terminology and notation, and to put the mathematics in a linear sequence that flows logically, but it is very likely that some imperfections remain.
-We ask the reader's forgiveness for any such infelicities, and welcome suggestions for improvement of the next edition.
-
+We ask the reader's forgiveness for any such infelicities, and welcome suggestions for improvement.
+%
+Errata and updated copies are available at \url{http://homotopytypetheory.org/book};
+the copy you are now reading is version \texttt{\OPTversion}and incorporates all errata with prior versions.
@andrejbauer Owner

Should there be a space between } and and?

@mikeshulman Owner

Unfortunately, the script that makes version.tex includes a linebreak in the definition of \OPTversion. So putting a space here resulted in a double-width space in the output.

@andrejbauer Owner

Well, how about if we fix the script instead?

@mikeshulman Owner

Feel free; that's your bailiwick.

@JasonGross Owner

If you want to fix the script, here is one possibility (I haven't actually tested it, but I'm pretty sure it'll work):

version.tex:
    /bin/echo -n '\newcommand{\OPTversion}{' > version.tex
    /bin/echo -n "$$(git describe --always --long)" >> version.tex
    /bin/echo -n '}' >> version.tex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@andrejbauer andrejbauer commented on the diff
macros.tex
((46 lines not shown))
+ % is an internal "my@newthm" version. Note that this does *not* use
+ % the "thm" counter, since we don't want that counter to get
+ % incremented when we pass through a newthm. Instead it creates its
+ % own my@newthm counter, which we never actually use.
+ \newtheorem{my@new#1}{#2}
+ \crefname{my@new#1}{#2}{#3}
+ % Instead of using the "my@newthm" counter, when we need to number a
+ % newthm, we call the special macro \newthm defined below.
+ \expandafter\renewcommand\csname themy@new#1\endcsname{\thenewthm}
+ % Finally, we define the "newthm" environment to first check
+ % validity of the fraction passed and then create the theorem.
+ \newenvironment{new#1}[2]{\checknewthmfrac{##1}{##2}\setcounter{@newthmnum}{##1}\setcounter{@newthmdenom}{##2}\begin{my@new#1}}{\end{my@new#1}}
+}
+% How to display fractional theorem numbers.
+% (In particular, we leave off the zero if it is there)
+\def\thenewthm{\ifnum0<\value{my@thm}\themy@thm\else\thesection.\fi$\frac{\arabic{@newthmnum}}{\arabic{@newthmdenom}}$}
@andrejbauer Owner

Is this going to use a diffeent font for the fractional part of the theorem number from the rest?

@mikeshulman Owner

I can't tell. Are you thinking because the fraction is in math mode and the rest isn't? I don't know any other way to do it --- there's no way to make a fraction except in math mode, is there?

@andrejbauer Owner

Let me experiment.

@JasonGross Owner

You could do something like \frac{\text{n}}{\text{d}}. Would that work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 84 additions and 10 deletions.
  1. +6 −2 introduction.tex
  2. +78 −8 macros.tex
View
8 introduction.tex
@@ -494,8 +494,12 @@ \subsection*{How to read this book}
Finally, recall that this book was written as a massively collaborative effort by a large number of people.
We have done our best to achieve consistency in terminology and notation, and to put the mathematics in a linear sequence that flows logically, but it is very likely that some imperfections remain.
-We ask the reader's forgiveness for any such infelicities, and welcome suggestions for improvement of the next edition.
-
+We ask the reader's forgiveness for any such infelicities, and welcome suggestions for improvement.
+%
+Errata and updated copies are available at \url{http://homotopytypetheory.org/book};
+the copy you are now reading is version \texttt{\OPTversion}and incorporates all errata with prior versions.
@andrejbauer Owner

Should there be a space between } and and?

@mikeshulman Owner

Unfortunately, the script that makes version.tex includes a linebreak in the definition of \OPTversion. So putting a space here resulted in a double-width space in the output.

@andrejbauer Owner

Well, how about if we fix the script instead?

@mikeshulman Owner

Feel free; that's your bailiwick.

@JasonGross Owner

If you want to fix the script, here is one possibility (I haven't actually tested it, but I'm pretty sure it'll work):

version.tex:
    /bin/echo -n '\newcommand{\OPTversion}{' > version.tex
    /bin/echo -n "$$(git describe --always --long)" >> version.tex
    /bin/echo -n '}' >> version.tex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+While page numbering may differ between copies, the numbering of sections, theorems, exercises, and equations will remain constant throughout the first edition.
+New theorems and equations may be added at the end of a section, or be given fractional numbers (thus Theorem 1.2.3$\frac12$ may be added between Theorems 1.2.3 and 1.2.4).
% Local Variables:
% TeX-master: "hott-online"
View
86 macros.tex
@@ -676,18 +676,77 @@
% Corollary 1.2 rather than Corollary 1.1. This makes it much easier
% for the reader to find a particular theorem when flipping through
% the document.
+%
+% We also allow for fractional theorem numbers, for theorems added
+% after publication in between existing theorems without changing
+% their numbers. To create a fractional theorem number, use the
+% environment "newthm" (or "newcor", "newlem", etc.) which takes two
+% arguments, the numerator and denominator of the fraction. Such
+% fractions must be strictly between zero and one, and must strictly
+% increase in between each pair of ordinary (integer-numbered)
+% theorems.
\makeatletter
+% We start by defining the primary theorem environment. The counter
+% "thm" is the one we will use for all theorem environments.
+\newtheorem{thm}{Theorem}[section]
+% Auxiliary counters which store the most recently used fraction.
+\newcounter{@newthmnum}
+\setcounter{@newthmnum}{0}
+\newcounter{@newthmdenom}
+\setcounter{@newthmdenom}{1}
+% This macro will be called to create and munge all theorem
+% environments, *including* the base one "thm" that we have already
+% created.
\def\defthm#1#2#3{%
- %% Ensure all theorem types are numbered with the same counter
- \newaliascnt{#1}{thm}
- \newtheorem{#1}[#1]{#2}
- \aliascntresetthe{#1}
- %% This command tells cleveref's \cref what to call things
- \crefname{#1}{#2}{#3}}
+ % The actual "theorem environment" we use internally is not "thm" or
+ % "cor", but rather "my@thm" or "my@cor". The aliascnt commands
+ % ensure that all such environments use the same counter "thm".
+ \newaliascnt{my@#1}{thm}
+ \newtheorem{my@#1}[my@#1]{#2}
+ \aliascntresetthe{my@#1}
+ % This command tells cleveref's \cref what to call things
+ \crefname{#1}{#2}{#3}
+ % Now we define "thm"/"cor"/etc. to be a wrapper around its my@
+ % version, which resets the "most recently seen fraction" counters
+ % afterwards.
+ \expandafter\def\csname #1\endcsname{\begin{my@#1}}
+ \expandafter\def\csname end#1\endcsname{\end{my@#1}\setcounter{@newthmnum}{0}\setcounter{@newthmdenom}{1}}
+ % Next we define the "newthm" environment for fractions. Again, there
+ % is an internal "my@newthm" version. Note that this does *not* use
+ % the "thm" counter, since we don't want that counter to get
+ % incremented when we pass through a newthm. Instead it creates its
+ % own my@newthm counter, which we never actually use.
+ \newtheorem{my@new#1}{#2}
+ \crefname{my@new#1}{#2}{#3}
+ % Instead of using the "my@newthm" counter, when we need to number a
+ % newthm, we call the special macro \newthm defined below.
+ \expandafter\renewcommand\csname themy@new#1\endcsname{\thenewthm}
+ % Finally, we define the "newthm" environment to first check
+ % validity of the fraction passed and then create the theorem.
+ \newenvironment{new#1}[2]{\checknewthmfrac{##1}{##2}\setcounter{@newthmnum}{##1}\setcounter{@newthmdenom}{##2}\begin{my@new#1}}{\end{my@new#1}}
+}
+% How to display fractional theorem numbers.
+% (In particular, we leave off the zero if it is there)
+\def\thenewthm{\ifnum0<\value{my@thm}\themy@thm\else\thesection.\fi$\frac{\arabic{@newthmnum}}{\arabic{@newthmdenom}}$}
@andrejbauer Owner

Is this going to use a diffeent font for the fractional part of the theorem number from the rest?

@mikeshulman Owner

I can't tell. Are you thinking because the fraction is in math mode and the rest isn't? I don't know any other way to do it --- there's no way to make a fraction except in math mode, is there?

@andrejbauer Owner

Let me experiment.

@JasonGross Owner

You could do something like \frac{\text{n}}{\text{d}}. Would that work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+% Reset the fraction at section boundaries too. This is a bit of a
+% hack; \@seccntformat is not intended for this.
+\let\my@seccntformat\@seccntformat
+\renewcommand*{\@seccntformat}[1]{\setcounter{@newthmnum}{0}\setcounter{@newthmdenom}{1}\my@seccntformat{#1}}
+% Test to make sure newthm fractions increase and are all in between zero and one
+\newcount\@xone
+\newcount\@xtwo
+\def\checknewthmfrac#1#2{
+ \ifnum0<#1\else\errmessage{Fractional theorem numbers must be greater than zero}\fi
+ \ifnum#1<#2\else\errmessage{Fractional theorem numbers must be less than one}\fi
+ \@xone=#1
+ \@xtwo=#2
+ \multiply\@xtwo by \value{@newthmnum}
+ \multiply\@xone by \value{@newthmdenom}
+ \ifnum\@xone>\@xtwo\else\errmessage{Theorem numbers out of order}\fi
+}
% Now define a bunch of theorem-type environments.
-\newtheorem{thm}{Theorem}[section]
-\crefname{thm}{Theorem}{Theorems}
+\defthm{thm}{Theorem}{Theorems}
%\defthm{prop}{Proposition} % Probably we shouldn't use "Proposition" in this way
\defthm{cor}{Corollary}{Corollaries}
\defthm{lem}{Lemma}{Lemmas}
@@ -745,6 +804,17 @@
\let\c@equation\c@thm
\numberwithin{equation}{section}
+% Fractional equation numbering. Use a numbered equation environment
+% like "equation", and inside it, call "newtag" with two arguments:
+% the numerator and denominator, as for "newthm". The same
+% restrictions apply (fractions must be strictly between 0 and 1, and
+% strictly increase in between ordinary integer-numbered theorems or
+% equations).
+\def\newtag#1#2{\checknewthmfrac{#1}{#2}%
+ \setcounter{@newthmnum}{#1}%
+ \setcounter{@newthmdenom}{#2}%
+ \tag{\thenewthm}}
+
%%%% ENUMERATE NUMBERING %%%%
Something went wrong with that request. Please try again.