The following is a summary of counter usage and manipulations available in LaTex.
The following commands have a counter associated with it:
- part
- chapter
- section
- subsection
- subsubsection
- paragraph
- subparagraph
- page
- equation
- figure
- table
- footnote
- mpfootnote
- enumi
- enumii
- enumiii
- enumiv
You have several possibilities to manipulate counters in LaTex:
\addtocounter {counter} {value}
increments the specified counter by the value.\newcounter {newcounter} [oldcounter]
defines a new counter. Option ‘oldcounter’ is to link ‘newcounter’ to ‘oldcounter’.\setcounter {counter} {value}
sets the counter to have the specified value.\usecounter{counter}
used as the second argument of the list environment to number list items (see list command).\value {counter}
produces the value of the counter and is useful for doing arithmetic with counters.\renewcommand {cmd} [args] [opt] {def}
general command to define/redefine new commands.
Counter values can be printed in different formats such as:
\alph
or\Alph {counter}
for letters (a…z or A…Z) .\arabic {counter}
for arabic numbers (1…9).\fnsymbol {counter}
printing various symbols: asterisk, dagger, double dagger, section mark, paragraph mark, double vertical lines, double asterisk, double daggers, double double daggers. The value of counters must be between 1 and 9.\roman
or\Roman {counter}
for roman numerals (I,II,III,IV,V,…,X,etc.)
Affan
Do you know of a way of defining newcounter such that I can have a separate macro that prints out my own heading? eg.
I want to use \creatTask{Develop a new Algorithm},
to expand into \textbf{TASK 1 — Develop a new Algorithm}.
Thank you.
tom
Hi!
Try the code below, I think it solves your problem. I am using a newcommand “\createTask” which you call each time you want to create a new task. You can modify the new command to your needs, e.g. add the dash, etc.
Tam Nguyen
Thank you Tom!
Felipe
I have a counter-related question. I’m writing the outline of a document and want the section headings to be called simply “Chapter 1”, “Chapter 2”, etc. However, I need to move things around (i.e. move entire sections up or down) which messes the numbering, and then I have to go a manually change all of the headings. Any suggestions on how can I reference the chapter number without having to use actual numbers?
tom
Hi Felipe,
You can use labels to reference many things including all headings. Just place the label command (\label{label:name}) below the heading and use \ref{label:name} to access the number.
Cheers,
Tom
Quasi
Fantastic idea! Many thanks!!
David
Hi, first of all, great blog. Anyway, do you know if there is any command that gets the max value of a counter in a list? Thing is, I need to typeset a list where the label is normally:
P 1 – This and that and that.
P 2 – This and also another thing.
However, if there is only one \item in the list, it should be typeset as:
Paragraph – I’m alone in this list!!
Therefore, when defining the \newenvironment, I will probably need to use, as a condition value for \ifthenelse, some command like \maxvalue{counter}, as in:
The question is, of course, is there such a command (maxvalue)? Is it something LaTeX can do?
Thank you very much, I can send you the sources if you want.
David
2noob2banoob
Don’t know if you still need it, but…
I think the easiest way is to manually label the last item, then in your environment definition check the counter value associated with that label. Not sure though because I’m not that much of an expert, but there is a package called lastpage which counts pages in a similar way. You do have to run latex twice to get the counter right.
Also, it may become problematic if you want several of those environments in your document, but maybe you can fix that by making the label name a variable which is passed as an argument to the environment. Then if you use a different label for each occurence of the environment you should be ok. Not exactly trivial though…
An example of the code in the document body: (don’t know how to do code layout on this blog, sorry about that)
I hope this works for you. I don’t have any experience with creating my own environment so I can’t test it unfortunately.
tom
Thanks for your comment!
For code,
[
sourcecode language=”latex”]
…
[
/sourcecode]
should work.
Cheers, Tom.
tom
Hi David,
If I understood your problem correctly, I do not think you can do it the way you propose, as Latex runs through your code sequentially and therefore cannot know the final value of a counter beforehand. Hence there is nothing like \maxvalue{counter}.
You would probably need to do it manually…
Tom
David
Thank you for your help, I was afraid of that, exactly. I guess I will need to figure out another automatic way of doing that (mixing latex/scripts probably).
Ehsan
Hi,
plz help me!!
How can i link footnote counter to pabe counter?
Thanks.
tom
Hi,
You can use the Latex variable “\thepage” to get the current page as a number.
Look at this post for how to customise header/footer:
http://texblog.wordpress.com/2007/11/07/headerfooter-in-latex-with-fancyhdr/
Hope this solves your problem. If not, let me know.
Ehsan
Hi,
Thanks,
In the above lesson (maybe!) you write
————————————————————————–
\newcounter {newcounter} [oldcounter]
defines a new counter. Option āoldcounterā is to link ānewcounterā to āoldcounterā.————————————————————————-
i want create such link (beetwen newcounter and oldcounter).
It means that when the oldcounter is increased the newcounter is set to zero!!
Thanks a lot.
tom
You can try to use \newcommand:
I am not sure whether this will work, you have to try it yourself.
Good luck:).
David
Hi again! I almost managed to do what I wanted, using \label and \ref to store a given value in the aux file. Here is what I did:
This is: for each myenumerate env in the text, there will be a correspondent enum:(number) label, and at the end of the processing, those counters will hold, as value, the total number of items in the environment, plus 1.
With 3 myenumerate ‘s, each with 1,4 and 1 numberof \item ‘s, respectively, I get a clean compilation, but:
2.
2.
3.
4.
5.
2.
So, I’m very close, but since I’m a total newbie in LaTeX, there is something simple I can’t realize. Could you help me? Maybe try it?
Thanks a lot.
Alex
How to change numbering of figures in a standard Latex article style from Figure 1: to Figure 1.
(i.e., colon to dot after numbers)
tom
Hi Alex,
You can actually customise your caption completely.
To answer your question, you need the package “caption2”:
Then you renew the “caption label delimiter” through:
If you want to have the colon back for whatever reason, just use the command again inside your document with a colon instead of a dot.
This should solve your problem.
Cheers,
Tom
Florian
Hi,
I am writing a document with many constants that I want to write $C_i$ with $i=1,2,…$, and such that I can make a reference to a specific constant later. So I tried to define a counter \cte, a command \newcte{label} that prints $C_\thecte$ and labels it with some label, and then another function \usecte{label} that would print the corresponding constant.
I tried:
But I don’t understand why this does not work. Moreover, I have an annoying problem: when I want to use this syntax in an align environment with a label, I get a multiple labels error…
Thanks in advance if anyone knows how to make this work (the way I tried or any other way!).
tom
Hi Florian,
What you did works perfectly, just that you forgot the dollar signs ($), even though you had them in the text. Here is the corrected code:
And now you can print what you wanted:
\newcte{bla}
->\ref{cte:bla}
-> 1Troy C.
Hi,
I’m using “book” as the document class. And I want to link chapters to parts, so whenever I create a new part, the chapter counter is reset to 0. The easiest way to do this would be to just add following code in the preamble:
Right? But LaTeX always complains that the counter “chapter” has already been defined.
How do I do this efficiently, without having LaTeX complain? Please help. Thanks in advance.
tom
Hi Troy!
The counter is indeed already defined. What you have to do is reset it to zero.
The following line after each “part-command” will do the trick:
Cheers,
Tom
Ganesh
Thanks a lot. I was searching for this info for long time.
tom
You are welcome! Best, Tom.
Troy C.
Hi Tom,
Thanks for your tip. I tried that, and at the first look, it’s the solution I was looking for. But only at the first look. See, I use PDFTeX. And setting the “chapter” counter to zero whenever I call “part” does the trick visually. This solution would work fine as a print. But my goal is PDF.
The problem is, let’s say I have two parts in my book, with various chapters in each part. Now, in the table of contents in the PDF, if I click on the second chapter of part II, the link doesn’t take me to the second chapter of part II. Instead, it takes me to the second chapter of part I. So internally, setting the “chapter” counter to zero every time part is called up messes with PDFTeX’s linking system.
Is there any way to avoid that? There has to be an elegant solution to this problem without having to program new \chapter or \part, because I want to be able to use my .tex files in other projects as well without having to change anything.
Thanks again. Cheers,
Troy
PLS
Hi Troy,
my answer comes probably a bit too late to help you but in case anybody else faces the same problem: Include the following command in your preamble:
Cheers,
PLS
tom
Hi Troy,
I see your point. The books I have seen usually have consecutive chapter numbering even over different parts. I couldn’t find a solution to your problem, sorry!
Cheers,
Tom.
Florian
Hi,
thank you for your answer. unfortunately, what does not work is that I cannot use this code inside an environment \begin{align} with a label, because then there is a conflict on the labels…
i have found a trick by using the package smartref, but if anybody has a better solution, I am interested!
venus
hello
I want for my math formula number, first have equation number then have chapter number, e.g.(34-2)
34 is equation number and 2 is chapter number
how can I do this?please guide me
tom
@venus
In Latex, you can always access the counter of a specific environment using \theenvironment, e.g. the equation-environment counter is accessed through
\theequation
.Your problem can be solved by redefining the equation counter as follows:
Cheers,
Tom
Erick
Hi all,
I have the appropriate “example” environment, and its respective ExampleCounter.
I want to be able to continue an “example”, as in:
Example a: xyz
Example b: xyz
Example c: xyz
Example b (continued): xyz
Example d: xyz
My question is:
How do you:
(1) set ExampleCounter = value of ExampleCounter of the (say the) second example (ie. Example b:)
(2) Use the counter to create the example: “Example b (continued):” (i.e. \begin{example}[continued] xyz \end{example}
(3) set ExampleCounter = value it had before step (1) —so that I can continue with the correct example labels…
Thanks in advance,
Erick
tom
Hi Erick,
I couldn’t find a nice answer to your questions (1) and (3).
Concerning question 2, a possible way to do it is the following:
and then
The disadvantage is, you always have to have the optional argument brackets when using the environment.
For (1) & (3), you can simply add and subtract from your counter:
This is obviously not dynamic, but I couldn’t think of a better solution for now, sorry.
Cheers,
Tom
venus
hello thnks for your worth help
Erick
First of all I wanted to thank Tom for his response. I also wanted to post a possible solution to my questions 1 and 3 that is somewhat more dynamic (although definitively not elegant).
Erick
pauld
hi all
I’m looking to define a new sort of section to my document where i store all my figures. It should be something like when you do \appendices your chapter titles change from Chapter 1,2,3 to Appendix A,B,C
I want this new section at the very end (after appendices, bibliography, etc), and when i type \figures for instance, chapter titles should change to Figures Chapter 1,2,3
What do you think is the best solution for this? And do the figurecounters automatically change too? (so they look like Figure 1.12, 2.34, etc)
dcheslow
I need to print a document in batches of pages. I’d LIKE to do this by creating separate documents for each batch of pages (the batches have different layouts and are printed on different paper so it makes some sense to separate them).
In order to do this, I need to set the starting page of each document. I haven’t had much luck modifying \thepage… it seems to be defined as a macro command somewhere deep in the bowels of TeX.
Any/all help and suggestions are welcome,
thanks.
dcheslow
Sorry… my bad… I found the (very simple) answer moments after posting:
Thanks anyway,
venus
i have a question. how can i start footnote number, from 1 in each page, as u know its continuous for each chapter
venus
hello
please help me who knows it, as you familiar with latex footnotes numbers
starts from 1 at the beginning of each chapter, but I want for each page
footnotes number starts from 1, how do it?
thank you
venus
hi
how can I clear the page number of the first page of each chapter, and second page of chapter start from 2 and continue?
thanx
Victor
I am writing a book where I would like to number the examples, and have them appear in a “listofexamples”. I would like the counter to be chpater name dash example number, also, I would like to be able to reference an example via \label \ref. How can I achieve this.
Thanks
tom
Hi Victor,
Thanks for your very interesting question. As this might be interesting to others, I decided to write a new post on that topic.
http://texblog.wordpress.com/2008/07/13/define-your-own-list-of/
I hope this is more or less what you were looking for. If you have any further question, don’t hesitate to contact me.
Best regards,
Tom
Victor
Great, I used:
however…
1. If I set example numbers to include chapter, than in the table of contents the example number overlaps with the text (i.e. the numwidth is not properly set).
2. Also, I would like to have an extra space in between the examples from various chapter.
Thanks
application
Hi! thanks for the great blog! I have a question. I have document with Chapters 1, 2, 3, and sub sections 1.1 1.2…. 2.1, 2.2 … so on.. How do I set a counter for a figure X that belongs to Chapter Y and subsection Z, so that its number will appear as Figure Y.Z.X ?
application
… and basically same question for tables…
tom
Hi!
What you would need to do is the following.
Define a new counter:
and tell Latex how you want your figure counter to look like:
If you want Latex to reset the counter everytime you start a new chapter you need to add this piece of code:
Hope this is what you were looking for,
Tom
application
Thanks a lot!
1sy8
Tom,
Your last tip can solve Troy C.’ s problem :
To change chapter number each time changing part, add in your preamble
chstef
Hi,
I am writing a book that contains a certain number of tables and figures.
I would like to include the total number of figures and the total number of tables in the front page.
I was wondering if there is way to do so automatically.
Thanks in advance.
tom
Hi,
Thanks for your question, which was rather tricky to answer :-). The problem is, that you first have to run through the document in order to know the number of figures.
I propose you write a macro with the code given below, so you don’t mess up your tex-file:
1. Open a new text-file and call numberfigure.sty.
2. Copy-paste the code below into the file and save it.
3. Add the
numberfigure
package to your Latex-document.4. Use
\pageref{NumberFigures}
to print the number of figures.I have to admit, the solution is not very nice and I would be happy if someone who is familiar with macros would post a better solution.
Here is the macro code for numberfigure.sty:
Cheers,
Tom
chstef
It worked!!! Not only for the tables and figures, but also for a user-defined floating environment as well. Thanks a lot for your prompt help.
Tip: Showing page 4 of 65 « Blog on Latex Matters
[…] I recently posted a comment on how to count the number of figures within your document. View […]
emurray
Hi,
I’m a little stuck with list numbering. I’m creating a list of assumptions in a paper. However, I would like the assumption counter to reset ONLY when the chapter number changes. In other words, I’d like the text to read:
Chapter 1, Section 1
~
Assumption 1.1
Assumption 1.2
~
Chapter 1, Section 2
~
Assumption 1.3
Assumption 1.4
~
Chapter 2, Section 1
~
Assumption 2.1
~
Currently though, the assumption counter resets every time I call the assumption environment. Here’s my code for the environment:
I’ve tried adding “[chapter]” to the end of the counter definition, but it still doesn’t ensure that the counter is reset only when the chapter changes. Any ideas? Thanks!
emurray
Ah, nevermind, I figured out a way around it. I added a new counter using
which keeps the total of the assumptions in a chapter. Then I changed the last two lines of the above code to:
Thanks though!
chstef
Hi again,
I have finished the book I was writing (Programming in MATLAB). The book is written in greek. Now, I am trying to generate a multilingual index (greek + english) using makeindex package without success. Can you give me any suggestion on which package do I have to use?
Thanks in advance.
Rob Golding » Custom Section Headings in LaTeX
[…] applied some logic! It’s very useful to know that LaTeX has a counter for everything. This particular post was very helpful in working out which ones to alter, and how. Share and […]
tahani
Hi, I hope your help.
I need to numbering the front pages of a document in Latex by I,II,III,IV,…
Thanks for your help
tom
Hello!
Use
and
Tom.
tahani
thank you for help me.. but I dont need this numbering in the full document only in the first pages befor my chapters
can you help me again??..
tom
Then just use the command several times whenever you want to change the style. In the beginning you start with:
and when you need arabic, do:
to switch back.
Try it!
Cheers,
Tom
tahani
Thank you very much for your interest ..
I look forward to help you later.
Tahani
Hello,
I have a big problem, if I add the figure in my latex document, this figure be in the wrong place. My code is
Regards,
Paul Vrbik
Tom,
I’ve made my own environment for Examples. I followed your advice above (see post : Application about adding sections and chapters to numbering).
Although the numbering is working, referencing examples does NOT work (that is, whenever I reference an example, it always says “1”).
I want to examples to be like
Example 1.3
Example \thechapter.\theexample
and I want to reference them in the same manner: e.g. Please see Example 2.27.
Thanks for help. Code follows.
tom
Hi Paul,
It seems what you are looking for is this.
Cheers,
Tom
Continuous list enumeration throughout the document with LaTeX | Sound and Complete
[…] and some credits: I wouldn’t come up with a solution if I haven’t readĀ this post, and this website. Huge thanks to the authors for their tips! 60.388072 5.331851 […]
Leanne Streja
Thank you for this great help.
wisconsin union theater parking
This a really great writeup by the author looking forward to come back more very soon.
toto
Hello for all,
I want to ask you blease.
How can I add the first pages (i-ii-iii- ….etc) to Contents in latex
thanks for help me
mAg
Hi Tom,
thanks for the great tips. I am having an issue with custom section numberings and I was hoping you can help me with that.
In a standard document (not book, etc), I wanted to number sections as “S.1”, “S.2”, etc. and Appendices as “S.A”, “S.B”, etc.
Do you know how this can be done?
Thanks!
tom
Hi there,
You can use this:
In case you are using
\tableofcontents
, you may also need to change the space between the number an the heading:Best, Tom.
prasad
Hi tom,
I am new to latex, we are creating a pdf which consists of tables. when the table row contains more information its is getting overlapped with the pdf footer. here we are using longtable for table creation.
Please suggest a solution for not to overlap with the footer.
Thanks,
Prasad.
tom
Hi Prasad,
A
longtable
automatically “breaks” tables that are too long and reach into the margin. You can find some sample code here that may help you setting up yourlongtable
properly. Best, Tom.prasad
Hello Tom,
Whats happening in my case is i have a row data which will not fit into a single page. In this case its over lapped with footer and it is not continuing to next page.
Thanks in Advance,
Prasad.
tom
Hi Prasad,
I see what your problem is. However, I don’t know how to solve it, sorry. I tried various things without success. Maybe somebody else can help…
Cheers, Tom.
prasad
Hello,
I have a problem in finding wether a pdf file is already opened by the user or not.
Can any one help me?
Prasad.
tom
Hi Prasad,
I’m not sure what you are trying to do. Is your goal to check if a file to be included in a Tex-document is readable? This page shows how to check if a file that you want to include exists.
Best, Tom.
mohammad
Dear Tom,
From the blog, it seems that you are the guy who can help me..:) I need to number my figures in following 1,2a,2b,3,4….. way. As I understood, I have to use
\newcouter
, this kind of stuff. But I could not figure out how to do it properly. Here is my code :I would like to put the label as 2a and 2b then again 3, 4….
please help.
regards
Ullah
tom
Hello!
I suppose the two figures (a) and (b) belong together and should be displayed together? Please have a look at the
subfig
package, which is a much cleaner way to generate sub-figures and automatically numbers the figures the way you want.Here is a post I wrote some time ago about
subfig
including sample code. You may also want to have a look at the package documentation.Let me know if you have any more questions.
Best, Tom.
mohammad
Hello,
Thanks a lot for you reply. These documents will help me for sure. But, I need to make two different figures with two different captions and labels, (a) and (b) don’t belong together. Some complete different figures in different places of the article like 1,2,3,4,5.. except I want to make it like 1,2a,2b,3,4,5… one figure after another figure, with there own caption. By doing normal way I can make figures and Latex number them automatically Fig1, Fig2, Fig3…. But I want to have Fig1, Fig2(a), Fig2(b), Fig3….
I guess, this time I made it clear..:)
thanks in advance..
cheers
Ullah
tom
Hey Ullah,
I put together some code that will modify
\thefigure
the way you need it. Put it into your preamble.The only thing you have to do now is to call
\modfig
to start the subfigure numbering and\resfig
to stop it and continue normal figure numbering.Best, Tom.
mohammad
Hi,
Thanks a lot. I feel there is some bug in the code or may be I am too novice to understand.:( When I call \modfig and \resfig in the first figure it gives 1a number. But when I call at the beginning of my second figure and close at the end of third figure, it gives 2b and 2d. where I was expecting 2a and 2b. But I found another blog, and I fixed it now..in the following way..
In to preamble:
Then at the beginning of the 2nd figure
then beginning of the third figure
and at the end to continue normal figure numbering.
this gives me 1,2a,2b,3,4,5 …..
regards
Ullah
tom
That looks good and makes sense in case you use it once only.
By the way, you don’t need to load the
subfigure
package, it’s not needed here.Best, Tom.
usha
Hi Tom,
I have seen ur solutions in this blog.They are helpful to me a lot.I have some problem regarding the alignment of numbers in listoffigures.The number and title are overlapping.I couldnot figure it out.Could you help me to solve this issue.
tom
Hi usha,
Please have a look at the tocloft package and the comments on this post (e.g. here).
Best, Tom.
Alec
(Moved here by Tom.)
Is there a simple way to have counters (e.g., equations) in a document pick up where the previous document left off? Obviously, I can always manually set the counter at the beginning of the new doc, but discovery of the xr package got me to thinking that perhaps there’s a similarly automated way to do this.
Thanks!
AJ
tom
Hey Alec,
I moved your comment to this more suitable post. So here is my response. I tried quite a few things and I could not find a simple way to use counters across multiple documents. You could give the
zref
package a try (documentation).In some cases,
include
may do the job. You can compile a list of individual tex-files once, generating all the counters, page-numbers and labels correctly. They will be stored in meta-files (e.g. *.aux). Next, you compile only a subset (one or more) usingincludeonly
:Best, Tom.
Alec
Thanks so much! I’ll give it a try.
best,
Alec
tom
Sure, good luck :-). Tom.
Mohsen
Hi,
I was curious to know that is there any possibility that I manage to have two different kind of numbering for figures. For example I have a picture of a table and I want to have a separate numbering for figures of tabels!
Sincerely,
tom
Hey,
Have a look at the
trivfloat
package. Also, here is a code example in the comments of this previous post on defining your own list of….Let me know if you have any problems.
Best, Tom.
akismet-26da50ae2122a58d3b4a58f76fac4741
Hey,
Thank you for usefull information.
I see that you are pro in latex docs, so I would like to know if there is a possibility to show the equation counter on a different side of a document, because it is on the right side of a page by default.
I am looking forward to hearing from you.
tom
Hey!
You can use the documentclass option
leqno
for equation numbering on the left side. Here is an example:Best, Tom.
akismet-26da50ae2122a58d3b4a58f76fac4741
Works. Thank you very much.
tom
You are welcome. Tom.
Filipe
Is there a way to count the number of entries in a bib file? I am writing my CV and wished to have something like:
Oral Presentations (3):
Reference1
Reference2
Reference3
Poster presentations (4)
Reference 4
Reference5
Reference6
Reference7
What I want is to print the numbers inside the parentheses (oral presentations are in oral.bib and poster presentations are in poster.bib)
Thanks
tom
Hi Filipe,
Here is a minimal working example. It’s certainly not the most efficient way to do it, but it works. You’ll have to run “bibtex poster” and “bibtex oral”. Best, Tom.
Filipe AtaĆde
What if I use \nocite? I only get 0’s… I wish to count the entries in the bib file. is that possible?
tom
Hi Filipe,
The command
nocite
is tricky. Try the biblatex package which offers great flexibility. Furhtermore, you may find these answers to a somewhat related question useful.Best, Tom.
Filipe AtaĆde
Actually I did change every \cite… to \nocite… and it works perfectly. The only thing I which it could do additionally would be instead of having to add every reference by by hand using the \nociteoral{ref1}\nociteoral{ref2}\nociteposter{ref3}… i could just \nociteoral{*}\nociteposter{*} but sadly it won’t work…
tom
Thanks for the follow-up. Indeed, according to the documentation, the star as a placeholder for all references in a bib-file was not implemented. Best,Tom.
Mads
Great blog!! This may not have a solution (possibly, due to it’s narrow application base):
I am writing up mathematical models in LaTeX [i.e. a lot of equations] and then coding up models in Java/C++/C algorithm for implementation. To keep track of which part of code belongs to which equation, I comment the code with the related equation number [company policy!!]… this works when document is growing from the bottom. However, I now have to go back and add sections here and there in document, which screws up numbering and my code comments. The only solution I can see to dynamically link my equation numbers to my code is the following:
1) Label each equation (100s of ’em) inside LaTeX and in relevant code
2) Utilize *.aux file + script to extract labels and equation number
3) Run code through another script to append new eqn number to label
But is there some better way to extract equation numbering without labeling everything in LaTeX? From what I can tell, only if I label equations do they appear in *.aux file.
Or for short-term solution, is there a way to keep old equations numbers and just increment LaTeX counter for every additional equation — to avoid overwriting old equation numbering?
Any ideas? Thanks in advance!!
tom
Hi Mads,
Thanks for your interesting question. I don’t know the exact policy of your company on identifiers. In case you can use any identifier format (e.g. no consecutive numbering, etc.), I suggest using the equation label, since it remains the same when the document is changed. Using the showlabels package, you can print the label into the margins for example.
Since you have so many equations, you might also find the catchfilebetweentags package useful. It lets you store chunks of code in a text file and load them. I’m not sure if this is useful, but with this package you might even be able to automatically fetch the code of the equation implementation and add it to the LaTeX document using listings.
In case you prefer using the actual equation numbers, say because you have a list of equations, what comes to my mind is use any of the tocloft commands to change the entries and extend it to write the equation numbers to a file that is easily parseable.
Hope you find my thoughts useful. I’m sure you’ll find a solution that suffices the requirements and is convenient.
Cheers, Tom.
Filipe AtaĆde
Is it necessary to be a code number or could it be a code name? If so, it would be rather easy just to set names… Can you do that? (That must be exhausting do, to name hundreds of equations…) I can’t think of any other way to do it besides that outer script you mentioned.
Oskar
Hi.
Is there a way to compute the actual (or physical) page count (current and possibly last)?
Or, otherwise phrased, is there a {globalpage} counter that is indifferent to anything the user does to the {page} counter?
To clarify the question suppose you reset counter{page} as you go (e.g., preface in roman+body in arabic, as found in many texts, or you use the \include{} command and skip some sections).
Suppose now that for typographical reasons you would like to understand whether the last page is a multiple of 4 or not (as to insert extra blank pages, for example). If the page counter is never reset, that’s easy. But if the page counter does get reset, this becomes a problem.
tom
Hi Oskar,
An interesting question. Yes, there is a way to determine the absolute number of pages using the zref package. Here is how:
Disha
In this blog, I found that I can change my page numbering from arabic to roman. But in my thesis, cover page must be without page number then few pages in roman page numbers and then rest of pages english numbers.
http://ashishrevar.com/2010/09/latex-redefine-numbering-in-figure-caption/
This page is only useful to change the number style but how to unset page numbers in cover page?
tom
Hi Disha,
Try the following to switch off page numbering for the first few pages.
Casey
I am using \begin{multline}…\end{multline} for some very long equations that span more than 60 lines. I would like to refer to specific lines in such equations. I have defined a counter, incremented it, and print a small number after each line. To avoid manual referencing of the lines I would like to refer to, I have attempted to use the \label command along with \refstepcounter. While this works fine outside the equation environment, it does not work within the multline. Any suggestions for this unusual application?
tom
Hi Casey!
Thanks for this question. In fact, you could just use align. See the example below.
Casey
Hi Tom,
Align will not do the job because the 60+ line expression is indeed one equation and thus needs to be numbered along with the other equations in the document consistently. What I need to do is to refer to individual lines within this one equation. Thus I needed embedded numbering that can be referenced. Sorry for not being more clear.
tom
Hi Casey,
Please provide a minimal working example and I’ll try to help you with the problem.
Tom.
Casey
tom
Thanks for the code! The code below works (apart from hyperref, which I didn’t test). I took the idea from here. HTH, Tom.
Casey
Thanks Tom! This solution will work.
Paul
Hi Tom,
Using documentclass{book} I have \setcounter{secnumdepth}{3} before \mainmatter. For one of the chapters this setting is one too deep, so I want to change it for that chapter only. I’ve tried resetting within the chapter, but to no avail. Do you have a solution to this.
Thanks a lot, in anticipation,
PaulT.
Paul
Hi Tom,
I left my previous post when frustrated after spending some time googling but failing to find a solution. However, I got the google question right today and now have the solution, which is simple.
Cheers,
PaulT.
tom
Thanks for getting back to me. Would you mind to post the solution that worked for you? Thanks, Tom.
Paul
Hi Tom,
The solution was to use the asterisk answer—i.e. include an asterisk in the section heading: e.g.
\subsubsection*{Arguments}
. This prevents the section heading being listed in the table of contents (toc).Cheers,
PaulT.
tom
Paul, thanks for posting the solution, appreciate it! Best, Tom
Federica
Hello š
I am writing my Master’s Thesis and I have a big big problem: I have to put 87 figures, two for page, so I am using the \subfloat command.
When I compile I get the error Counter too large. How can I solve it? My figures are labeled as A, B, C…..what’s the right way to continue labelling them AA, BB, CC… and so on?
Thank you in advance,
Fede
tom
I think with the alphalph package you should be able to fix your problem. Let me know if you can’t get it to work. In that case, please provide a minimal working example.
Best, Tom
mik2232
Hello,
I want to use additional counters for page number in appendices, so that the main numbering (bottom) goes from beginning to the end of the document, and header (if the page is in appendix) must contain something like “Appendix 1. Page X of XXX” where XXX is the number of pages in appendix. Can I do it with custom counters? Thanks.
tom
Hi there,
Thanks for your question. The lastpage package does what you are looking for. I wrote a short post about it some time ago.
HTH,
Tom
nils
Hello,
How do i stop counter? I need to stop counting pages at the appendices i have following;
Best Wishes and thanks in advance
tom
Hi Nils,
I assume you use the lastpage package as described in this post. The easiest solution would be to place a
label
on the last page (before the appendices) and then use\pageref
to print that page number.Best, Tom
Joe
Hello Tom,
Thank you for the awesome blog.
I am new to Latex environment. I looked at your response (11/9/2011) related to custom
toc. Is there a special package that I need to download from CTAN ? Currently in list of tables I have VIII.1, VIII.2 etc that needs to changed to A2.1, A2.2 etc.
2. How do i setup margins 1 Ā½ā on the LEFT and 1ā on the OTHER THREE SIDES for the entire document ?
Thank you.
tom
Hi Joe,
1. To change the way a counter value is printed, you won’t need a package.
2. Use the geometry package to set the margins globally.
HTH,
Tom