Page LayoutProblems with the numbering of subsections

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
kessenchu
Posts: 2
Joined: Thu Mar 05, 2009 3:03 pm

Problems with the numbering of subsections

Post by kessenchu »

I am writing my notes of class in latex, and I would like to get the following result:

1. Algorithm (this is a section)
1.1 Newton's Method (this is a subsection of Method)
...
1.1 Example (this is a subsection of Example)
...
1.2 Example (another subsection of Example)

1.2 Lagrange Method (this is a subsection of Method)

Basically it is to have different counters depending whether you are making a reference to a Method or an Example. So maybe the numbers are repeated but they are referring to different contents.

Thank you.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

kessenchu
Posts: 2
Joined: Thu Mar 05, 2009 3:03 pm

Problems with the numbering of subsections

Post by kessenchu »

I finally found what I wanted, it is:

\newcounter{section_examples} % add a new counter
\newcounter{subsection_examples}[section_examples]
\stepcounter{section_examples} % increase the counter
\stepcounter{subsection_examples}

\subsection*{Example \arabic{section_examples}.\arabic{subsection_examples}}
The example 1.1

...
\stepcounter{subsection_examples}
\subsection*{Example \arabic{section_examples}.\arabic{subsection_examples}}
The example 1.2


If you do it in this way, you will always be able to handle your own counter.
I think it is pretty and elegant.
If someone find another way to do it, just post it, ^-^.

See you
Post Reply