Math & Science ⇒ Simple Counter Customization
-
- Posts: 5
- Joined: Tue May 31, 2011 1:01 am
Simple Counter Customization
Basically, I have several .tex documents which will later be compiled into a larger document using the \include{file.tex} command. Each document is a stand-alone file, which has its header completely designed by a specified number variable. For example, if the number is 8, then all the headers will autoformat to incorporate this. This flexibility is crucial because I need to be able to shuffle these at a whim. I would like then to be able to number the equations accordingly. Therefore, if the number variable is 8, then I need all equations in the document automatically numbered as (8.0, 8.1, 8.2) etc...
I realize that Latex has the \setcounter command to start counting at 8, and it also has the \numberwithin command to increment by .1 instead of 1. Unfortunately, the \numberwithin command needs to refer to a built-in feature of the document, for example the section. Since my documents are stand-alone files, they don't have sections or chapters for the \numberwithin command to understand. Is there a way to have \numberwithin recognize the number variable (E.G. 8) and number all equations as 8.1, 8.2 etc... Alternatively, can one define a custom \setcounter, that simply increments by .1 rather than 1.
Can anyone help with this? It's really holding me up!
Thanks
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
Simple Counter Customization
Here's an example:
Code: Select all
\documentclass{article}
\usepackage{chngcntr}
\newcounter{mycounter}
\counterwithin{equation}{mycounter}
\setcounter{mycounter}{8}
\begin{document}
\begin{equation}
8.1 = 8.1
\end{equation}
\begin{equation}
8.2 = 8.2
\end{equation}
Now let's move on to 9.
\refstepcounter{mycounter}
\begin{equation}
9.1 = 9.1
\end{equation}
\begin{equation}
9.2 = 9.2
\end{equation}
\end{document}
-
- Posts: 5
- Joined: Tue May 31, 2011 1:01 am
Simple Counter Customization
Code: Select all
\newcounter{EQCOUNTER}
{
\newcommand{\eqcounter}[1]{
\setcounter{EQCOUNTER}{#1}
}
\numberwithin{equation}{EQCOUNTER}
Code: Select all
\def \labnumber{8}
\eqcounter{\labnumber}