Document Classesto know the number of chapters at the preamble

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
lgassman
Posts: 3
Joined: Tue May 26, 2015 2:54 am

to know the number of chapters at the preamble

Post by lgassman »

Hi!

I am trying to extract a class file from a tex document in order to be able to reuse the style of document. This document has a pattern that I am trying to generalize in order to create automatically this code. The pattern is:
For each chapter it declares a counter in the preamble.
At begin of document, for each counter it uses \setcounterpageref{<chaptercounter>}{<chapterlabel>}%
At begin of chapter it uses:
\hypertarget{<chapterlabel>}{}%
\label{<chapterlabel>}{}%

This pattern lets to use \hyperlink{topofpage.\arabic{<chaptercounter>}}{<description>}
in any location of document to create a link to top of the chapter page.

Note the value of <chaptercounter> and <chapterlabel> are hard-coded in the document, and these change chapter to chapter. I wish create a command with parameters to replace hard-coded values.

I am not sure if this pattern is the best way of do it, but works fine.
My problem to generalize it is that I don't known the count of chapters at the preamble, so, I don't knwow how many counters I must declares in "afterPreamble" hook and how many of \setcounterpageref lines I need to write in "at begin document" hook.

Thanks!

Recommended reading 2024:

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

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

BlackForestrian

to know the number of chapters at the preamble

Post by BlackForestrian »

This is no answer, but just a question: Please clearify your question. The number of chapter in advance is possible with the cntperchap package, but I can't help more if there is not more information what you actually trying to achieve. It sounds very complicated at the moment.
Post Reply