Math & ScienceNumbering Results

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
dward1996
Posts: 16
Joined: Thu Nov 25, 2010 2:32 pm

Numbering Results

Post by dward1996 »

Hi

I wonder if anybody could help me out with an issue regarding numbering of results. I am currently writing my first large report in LaTeX, and am using the book document class, to enable me to use chapters as well as the various sectioning commands. Within each chapter, I have a number of theorem environments (such as Lemmas, Propositions etc.) and I have these numbered within a chapter. However, I also want to label specific formula's within the text (e.g. a specific line within a proof). I am using the align environment to do this. However, it naturally numbers the formula's in chapter 3 say as 3.1, 3.2, 3.3, the same numbering as I have for my theorems, thus causing ambiguity when I refer to them. Is there an easy way round this problem?

Sorry if this is really basic, or if I am not describing the problem very well, but I am very new to LaTex.

Thanks in advance for all your help.
Last edited by dward1996 on Sat Nov 27, 2010 7:20 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Numbering Results

Post by frabjous »

Well, how would you like things to work? Do you want a single counter for all the numbered stuff in the document? Do you want one of the counters to use a different style (roman numerals, or letters, etc.), or not to use the chapter number as a prefix? It's probably possible to work out any of these things, but it would help to know what you're after.

A minimal working example showing how you currently have things set up (e.g., are you using amsthm to create numbered environments as is, or something else, etc.)?
dward1996
Posts: 16
Joined: Thu Nov 25, 2010 2:32 pm

Numbering Results

Post by dward1996 »

Thanks for the quick response, and sorry for my vagueness. I've tried to make a minimal working example:

Code: Select all

\documentclass{report}

\newtheorem{theorem}{Theorem}[chapter]
\usepackage{amsmath}

\begin{document}
\chapter{Chapter 1}
\begin{theorem} Theorem 1
\end{theorem}
Proof: 
\begin{align}
y & = & mx+c
\end{align}
\hfill q.e.d.
\begin{theorem} Theorem 2
\end{theorem}
\end{document}
Ideally, I want the equations number within proofs to be numbered say as 0.alpha, 0.beta etc, however I'm not sure if this is possible, so basically any numbering that will not lead to ambiguity with the numbering I have for theorems (as I want to keep this numbering if at all possible).
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Numbering Results

Post by frabjous »

I guess I'm still a little unsure about what the 0 in 0.alpha and 0.beta is supposed to be. Are all the equations subordinate to a theorem, so that you want the number of each equation in each align to have its number begin with the one corresponding to the theorem, but then follow with a Greek letter?

If so, then maybe something like this would be appropriate. See the greekctr and chngcntr package documentation for more info.

Code: Select all

\documentclass{report}
\usepackage{amsmath}
\usepackage{greekctr}
\usepackage{chngcntr}

\newtheorem{theorem}{Theorem}[chapter]

\counterwithin{equation}{theorem}
\renewcommand{\theequation}{\thetheorem.\greek{equation}}

\begin{document}
\chapter{Chapter 1}
\begin{theorem} Theorem 1
\end{theorem}
Proof:
\begin{align}
y &=  mx+c\label{something}\\
z &=  mx+d
\end{align}
\hfill q.e.d.
\begin{theorem} Theorem 2
\end{theorem}
Proof.
\begin{align}
k &=  nh + l\\
w &= ej - 4
\end{align}
Let's refer to equation \ref{something}

\chapter{Another}

\begin{theorem} A new theorem.
\end{theorem}
Proof:
\begin{align}
2 + 2 &= 4\\
6 &= 3 + 3
\end{align}

\end{document}

If that's not what you're after, then do speak up. You can do just about anything.
dward1996
Posts: 16
Joined: Thu Nov 25, 2010 2:32 pm

Re: Numbering Results

Post by dward1996 »

Thanks for the reply, and sorry once again for not being precise.

My ideal situation would be for the equations within proofs of things in chapter 0 say, to be numbered 0.alpha, 0.beta, so "enumerated" within the chapter, but with an enumeration that distinguishes them easily from that of my theorems (theorem 0.1, lemma 0.2 etc.).

If this isn't possible, don't worry, as what you have suggested looks as if it will do the job just fine.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Numbering Results

Post by frabjous »

If this isn't possible, don't worry, ...
Are you always such a pessimist? As I noted, pretty much anything is possible.

I think this preamble should give you what you want:

Code: Select all

\documentclass{report}
\usepackage{amsmath}
\usepackage{greekctr}
\usepackage{chngcntr}

\newtheorem{theorem}{Theorem}[chapter]

\counterwithin{equation}{chapter}
\renewcommand{\theequation}{\thechapter.\greek{equation}}
dward1996
Posts: 16
Joined: Thu Nov 25, 2010 2:32 pm

Re: Numbering Results

Post by dward1996 »

Thanks for that. It works a treat.

One final question, but being fairly new to LaTeX, where should I have the chngcntr.sty file on my computer (I use a windows Pc, and use MikTex 2.8). I currently have it in the directory which my project is in, however ideally I would like it in one of LaTeX's directories so that I can use it all the time (no matter which directory my project is saved in). I have tried searching for advice on this, but the advice available just seems to creat error messages!

Again, sorry if this is a really trivial question, but thanks in advance for all of your help.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Numbering Results

Post by frabjous »

I use TeXlive on linux, not MikTeX on Windows, so I can't give you precise instructions, but it should be possible to install chngcntr using the MikTeX package manager.

On further testing, however, it appears not to be strictly necessary for this set-up. This by itself does the trick:

Code: Select all

    \documentclass{report}
    \usepackage{amsmath}
    \usepackage{greekctr}

    \newtheorem{theorem}{Theorem}[chapter]

    \renewcommand{\theequation}{\thechapter.\greek{equation}}
dward1996
Posts: 16
Joined: Thu Nov 25, 2010 2:32 pm

Re: Numbering Results

Post by dward1996 »

Thanks for that. It works just as you said.

Sorry for all the basic questions, but thanks for all of your help.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Numbering Results

Post by localghost »

Now that the problem is solved, please be so kind and mark the topic accordingly as written in the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.


Best regards and welcome to the board
Thorsten
Post Reply