1. 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.

  2. tom


    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.

    \bf{TASK \arabic{taskcounter} #1}
    \section{My three tasks}
    \createTask{Your first task}
    \createTask{Your second task}
    \createTask{Your third task}
  3. 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?

  4. 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.


  5. 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:

    \ifthenelse{\maxvalue{counter}=1}{Paragraph - }{P \arabic{counter} -}

    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.

    • 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)

      \item blabla
      \item blabla
      \item \label{lbl1} blabla
      \item \label{lbl2} blabla

      I hope this works for you. I don’t have any experience with creating my own environment so I can’t test it unfortunately.

  6. 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…


  7. 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).

  8. Ehsan

    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.

  9. tom

    You can try to use \newcommand:

    %arguments: newcounter, oldcounter, value

    I am not sure whether this will work, you have to try it yourself.
    Good luck:).

  10. 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:




    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.

  11. 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)

  12. 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.


  13. Florian

    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:

    	\refstepcounter{cte} \label{cte:#1} C_{\thecte}

    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!).

  14. 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:

    \refstepcounter{cte} \label{cte:#1} $C_{\thecte}$

    And now you can print what you wanted:
    \newcte{bla} -> C_1
    \ref{cte:bla} -> 1

  15. Troy C.


    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.

  16. 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:



  17. 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,

    • 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:



  18. 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!


  19. Florian

    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!

  20. venus


    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

  21. @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:



  22. 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,

  23. 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:

    Example \theexamplecounter#1:}{\\}

    and then

    \begin{example}{ (continued)}

    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:

    \begin{example}{ (continued)}xyz\end{example}

    This is obviously not dynamic, but I couldn’t think of a better solution for now, sorry.


  24. 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).

    %First we need to save counter before the example that we wish to %continue later (say save its value in the newcounter 'ex')
    \newcounter{ex} \setcounter{ex}{\value{examplecounter}}
    %When where we want to continue the example we can load the
    %saved counter (we need to save the current counter value in the %newcounter temp ---so that we can restore it later)
    %We continue the example (as Tom showed)
     \begin{example}{ (continued)}xyz\end{example}
    %Finally we restore the counter value


  25. 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)

  26. 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,


  27. dcheslow

    Sorry… my bad… I found the (very simple) answer moments after posting:


    Thanks anyway,

  28. venus

    i have a question. how can i start footnote number, from 1 in each page, as u know its continuous for each chapter

  29. venus

    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

  30. venus

    how can I clear the page number of the first page of each chapter, and second page of chapter start from 2 and continue?


  31. 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.


  32. Great, I used:

    \newcommand{\listexamples}{List of Examples}
     \vspace*{0.2in}\par\noindent\sqrblt\textbf{Example \theexamples. #1}

    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.


  33. 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 ?

  34. 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,

  35. 1sy8


    Your last tip can solve Troy C.’ s problem :

    To change chapter number each time changing part, add in your preamble

  36. chstef


    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.

  37. 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:



  38. 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.

  39. emurray


    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:

        {\begin{list}{Assumption \arabic{chapter}.\arabic{assump}:}

    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!

  40. 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!

  41. 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.

  42. 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

  43. 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??..

    • 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!


  44. Tahani

    I have a big problem, if I add the figure in my latex document, this figure be in the wrong place. My code is

    \caption{hyperplane} \label{labelname}


  45. 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.

    	\par\medskip\noindent\textbf{Example~\theexample ~{\normalfont (#1)}.}
  46. 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

  47. 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?


    • 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.


      • 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 your longtable 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,

      • 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.

  48. prasad

    I have a problem in finding wether a pdf file is already opened by the user or not.
    Can any one help me?


    • 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.

  49. 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 :

    \caption{Time dependence of the number of defects.}
    \caption{Time dependence of the number of defects. The curves are averages of twenty irradiations.}

    I would like to put the label as 2a and 2b then again 3, 4….

    please help.


    • 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.

  50. mohammad


    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..


    • 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.

  51. mohammad


    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 …..


    • 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.

  52. 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.

  53. 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.



    • 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) using includeonly:


      Best, Tom.

  54. Mohsen

    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!


  55. akismet-26da50ae2122a58d3b4a58f76fac4741

    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.

  56. 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):

    Poster presentations (4)
    Reference 4

    What I want is to print the numbers inside the parentheses (oral presentations are in oral.bib and poster presentations are in poster.bib)


    • 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.

      \usepackage{multibib, totcount}
      Poster Presentations (\protect\total{postercount}),%
      Oral Presentations (\protect\total{oralcount})}
      First poster reference: \citeposter{posterref2012}
      Second poster reference: \citeposter{posterref2011}
      First oral reference: \citeoral{oralref2012}
      • 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…

      • 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.

  57. 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!!

    • 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.

  58. Oskar


    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.

    • Hi Oskar,

      An interesting question. Yes, there is a way to determine the absolute number of pages using the zref package. Here is how:

      \usepackage[user, lastpage, abspage]{zref}
      \pagenumbering {roman}
      \pagenumbering {arabic}
      Last page number: \zpageref{LastPage}; absolute page number: \zref[abspage]{LastPage}.
    • Hi Disha,

      Try the following to switch off page numbering for the first few pages.

  59. 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?

    • Hi Casey!

      Thanks for this question. In fact, you could just use align. See the example below.

      	y_1&=a_1x_1+b_1 \label{eqn:one} \\
      	y_2&=a_2x_2+b_2 \nonumber \\ % omit number
      	y_3&=a_3x_3+b_3 \label{eqn:three}
      See \ref{eqn:one} and \ref{eqn:three}.
      • 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.

      • Hi Casey,

        Please provide a minimal working example and I’ll try to help you with the problem.


  60. Casey

    %.....Tiny line numbering for long equations
    Here is a minimal example:
    a = b + \dots \eln \\
    c + d \dots \eln \\
    e + f \dots \eln \\
    \dots+g + h \dots
    The real application has a single equation that spans more than 60
    full lines, and I would like to be able to refer to the line numbers
    using a label construct within the equation, which I number using a
    defined counter as shown above.
    • Thanks for the code! The code below works (apart from hyperref, which I didn’t test). I took the idea from here. HTH, Tom.

       Line $(\arabic{refeqc})$}
      a = b + \dots \eln \\
      c + d \dots \eln \\
      e + f \dots \eln \\
      \dots+g + h \dots
      Referencing the equation: \ref{eqn:dummy}
      Referencing lines: \eqqref{lnl:2}
  61. 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,

  62. 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.

  63. 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).

  64. 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,

  65. 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.

  66. nils

    How do i stop counter? I need to stop counting pages at the appendices i have following;

    \fancyfoot[C]{Page \thepage \ of XXX}
    \pagenumbering{arabic} %use arabic page numbering in the mainmatter

    Best Wishes and thanks in advance

    • 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

      \usepackage{blindtext, fancyhdr}
      \fancyfoot[C]{{\thepage} of \pageref{LastContentPage}}
  67. 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.

    • 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.



Leave a Reply