## LaTeX forum ⇒ Document Classes ⇒ Create customised references

Information and discussion about specific document classes and how to create your own document classes.
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

### Create customised references

Hey,

My document might look like the text below:

Paragraph 1: Lie groups represent the best-developed theory of continuous symmetry of mathematical objects and structures, which makes them indispensable tools for many parts of contemporary mathematics.
...
As discussed in Paragraph 1 we conclude ...

I would like to use references, i.e. something like this:
Paragraph 1: Lie groups ... mathematics. \createhiddenlabel{mylabel}{Paragraph 1}...As discussed in \ref{mylabel} we conclude ...

Basically I would like to create reference points which are hidden. Is this possible?

Tags:

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
Are these »Paragraph 1« like paragraphs actually parts that should be indicated by a sectioning command but should not appear in the table of contents? In that case I would probably use a customized \paragraph and set the counters secnumdepth and tocdepth accordingly. Here is an example:


More fine control over the layout for the \paragraph command would be possible through the titletoc package instead of LaTeX's low level command \@startsection that I have used here.

Regards
site moderator & package author

TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm
Thanks a lot for that, but basically what I want/need is a simple command like

\CreateAnInvisibleLabel[labelname]{Legendre}

which creates a hidden reference point so that I can access it, e.g.

... as defined in the \ref{labelname} polynomials ...

which gives me

... as defined in the Legendre polynomials ...

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
Well, LaTeX's labels always refer to a counter, i.e. a specific number associated with something like a section or a table caption. The \ref command always only prints the value of the corresponding \the<counter> macro which means you'll get the referenced number. For what you want one would need to define a different label/reference system that writes the words you want to have saved to the aux file and a custom ref command that retrieves it. Maybe this (note that it needs two compilations):


Regards
site moderator & package author

TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm
Thanks a lot! I changed \savelabel to the following so that the label is actually hidden (which is what I wanted).

\newcommand*\savelabel[2]{%   \immediate\write\@auxout{%     \noexpand\global\noexpand\@namedef{mylabel@#1}{#2}}}

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
You can also use this with hyperref, by the way. It has the macros \hypertarget{<label>}{<text>} and \hyperlink{<label>}{<text>} that could be used by themselves or included in the above definition:


Regards
site moderator & package author