LyXCross reference as part.section.#

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
User avatar
-S8-
Posts: 3
Joined: Fri Jun 03, 2011 4:59 pm

Cross reference as part.section.#

Post by -S8- »

Hi to all,
it bothers me spending my first post asking for help, but here I am. :P

I'm using the article document class and I structured my work in Part/Section/Subsection; using the command \@addtoreset{section}{part} I reset the section numbering for each part. When I use cross-reference for formulas, images, etc. it gives me the format section.#, but it can be misleading due to the reset, so it will be preferable to have part.section.# format.

I think I have to edit the refstyle package or use a preamble, but I don't know how.

Can someone help me?
Thank you
Last edited by -S8- on Wed Jun 08, 2011 7:03 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Cross reference as part.section.#

Post by Stefan Kottwitz »

Hi,

you could redefine \thesection:

Code: Select all

\renewcommand*{\thesection}{\thepart.\arabic{section}}
Or use the chngcntr package and \counterwithin, or if you use amsmath,

Code: Select all

\numberwithin{section}{part}
instead of \@addtoreset.

Stefan
LaTeX.org admin
User avatar
-S8-
Posts: 3
Joined: Fri Jun 03, 2011 4:59 pm

Re: Cross reference as part.section.#

Post by -S8- »

Thank you! I've tried both options and it works! :D


Actually they change also the TOC and all section and subsection in the part.section format, but I just want to redefine the cross-references. That's way I think the problem is in the refstyle package.
Now I realize that I don't know if what I'm asking is possible (in an easy way).

Anyway, Thanks
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Cross reference as part.section.#

Post by Stefan Kottwitz »

Perhaps think again about it. How do you see a difference then between section 2 in part 5 and section 2 in part 4? It would be consistent, if you would use the part number with section number in references, if you would use the part number in the section number as well. Note that you can refer to sections as well. It would be strange to see "Section 2" a third time (in part 3), but refer to it as Section 3.2. And numbers in the table of contents are of course references.

Stefan
LaTeX.org admin
User avatar
-S8-
Posts: 3
Joined: Fri Jun 03, 2011 4:59 pm

Cross reference as part.section.#

Post by -S8- »

Hi, I managed to obtain what I wanted. I've used the following preamble:

Code: Select all

\renewcommand{\thepart}{\Roman{part}}
\renewcommand{\theequation}{\thepart.\thesection.\arabic{equation}}
\renewcommand{\thefigure}{\thepart.\thesection.\arabic{figure}}
So now I can cross reference formulas and images as part.section.number.

However I'm still thinking about your advice to number in the same way sections. ;)
Post Reply