Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What I want

\newtheorem{thm}{Theorem}

\begin{thm} A \end{thm}
\begin{thm} B \end{thm}
\begin{thm} C \end{thm}

Ends up generating

Theorem 1 A.
Theorem 2 B.
Theorem 3 C.

What I want instead:

Theorem 3 A.
Theorem 2 B.
Theorem 1 C.

Why would anyway want this insanity?

I'm logging ideas I'm considering in LaTeX.

I want everything appear in reverse chronological order (i.e. newest ideas first; oldest idea last.)

Now, I want the numberings to remain valid across versions -- i.e. when I add a new theorem, I want old theorem 20 to remain as theorem 20 [thus all the discussions about theorem 20 do not suddenly become mislabeled.]

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

If you go

\let\oldthm\thm
\def\thm{\addtocounter{thm}{-2}\oldthm}

it will count backwards, you would need

\setcounter{thm}{4}

at the start, either manually, or by counting the number of thm used last time and setting it automatically from a previous run.


a complete document automating the resetting

\documentclass{article}
\usepackage{amsthm}

\newtheorem{thm}{Theorem}
\let\oldthm\thm
\def\thm{\addtocounter{thm}{-2}\oldthm}

\makeatletter
\def\finalthm{0}
\AtEndDocument{%
\immediate\write\@auxout{%
\string\gdef\string\finalthm{\the\value{thm}}}%
}
\AtBeginDocument{%
\setcounter{thm}{\startthm}
\addtocounter{thm}{-\finalthm}
\stepcounter{thm}%
\immediate\write\@auxout{%
\string\gdef\string\startthm{\the\value{thm}}}%
}
\makeatother
\begin{document}



\begin{thm} A \end{thm}
\begin{thm} B \end{thm}
\begin{thm} C \end{thm}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.