Text Formattingreferencing while the sections have * in them

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
pemfir
Posts: 23
Joined: Sun Aug 12, 2012 11:30 pm

referencing while the sections have * in them

Post by pemfir »

Hello I have the following code, and when i want to cross reference different sections in the appendix, I get basically nothing (blank). Now this may make sense since I am using \section*{} which removes the numbering in the headings, but I was wondering if there is a way I can manually assign a string+value to the label of a section. For example, can I say \subsection*{Appendix Subsection 1 }\label{2}[App.1], so every time I want to cross reference \ref{2} it automatically outputs App.1 ?

Thank you !

Code: Select all

\documentclass[10pt,a4paper]{article}
\begin{document}
this is the first reference: \ref{1}  

this is the second reference: \ref{2}

this is the third reference: \ref{3}

\section*{Appendix}\label{1}
\subsection*{Appendix Subsection 1 }\label{2}
\subsection*{Appendix Subsection 2 }\label{3}
\end{document}
Last edited by cgnieder on Sat Jun 22, 2013 5:13 pm, edited 2 times 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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

referencing while the sections have * in them

Post by cgnieder »

Basically you can't: the star form not only removes the number from the sight but also prevents that the section counter is stepped. With a \label always the last counter that has been stepped by \refstepcounter is referenced.

Now, there still are ways. You could, for example, introduce an own counter, manually step it and then reference it but I don't think this is wise: if I as a reader read a reference to App. 1 and nowhere found it because there actually is no appendix 1 (!) I'd be at least confused. Why don't you simply use numbered sections?

Regards
site moderator & package author
Post Reply