Add support for \Nameref alongside \NameRef

Udicoudco udifoglle at gmail.com
Sun Oct 2 20:04:35 UTC 2022


On Fri, Sep 23, 2022 at 3:32 PM madmurphy <madmurphy333 at gmail.com> wrote:
>
> LyX allows to use \NameRef for referencing labels. However most of the times I find \Nameref (with a lowercase “r”) more useful, and so I end up manually writing \Nameref{...} in a LaTeX box in a LyX document (which has the inconvenient that the argument is not automatically synchronized if for any reason I rename the label).
>
> Would it be possible to add \Nameref to the list of LyX supported referencing systems?
>
> --madmurphy

Hi,

I do not know the command \NameRef and did not find any reference to
it on the internet. I checked all the referencing formats in
LyX2.3.6.1 and it seems that LyX supports the command \nameref (but on
the GUI the label is titled with NameRef:) that is provided by the
nameref package.

To solve your query, you can write

        \usepackage{nameref}
         \AtBeginDocument{\let\ref\Nameref}

in the preamble, and use the default referencing format. If you use
the \ref command in your document, you can "sacrifice" a different
format that lyx supports, but not \nameref or \pageref, as \Nameref
uses those.

Note that the \AtBeginDocument is important because hyperref might be
changing the ref command at the beginning of the document as well (to
my  knowledge it defines \autoref at the beginning of  the document, I
did not check about \ref), also, if hyperref is loaded there is no
need to load nameref, as hyperref loads it internally.

Regards,
Udi
> lyx-devel mailing list
> lyx-devel at lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-devel


More information about the lyx-devel mailing list