Add support for \Nameref alongside \NameRef
madmurphy
madmurphy333 at gmail.com
Sun Oct 2 22:19:22 UTC 2022
Hi Udi,
I was mistaken because LyX shows it as NameRef: chap:duis-feugiat-facilisis,
but in reality the example attached, if exported to LaTeX, uses
\nameref{...} (all lowercase). What I often find more useful however is
\Nameref{...} (with a capital “N”) – you can find it too in the example
attached (no need to include packages).
--madmurphy
On Sun, Oct 2, 2022 at 9:04 PM Udicoudco <udifoglle at gmail.com> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221002/da754fd2/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nameref_example.lyx.zip
Type: application/zip
Size: 5293 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221002/da754fd2/attachment-0001.zip>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nameref_example.pdf
Type: application/pdf
Size: 89023 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221002/da754fd2/attachment-0001.pdf>
More information about the lyx-devel
mailing list