Discussion:
Automatic Reference Naming is not working in Lyx2.0 with the thesis template
Ruida Yun
2011-05-23 21:22:08 UTC
Permalink
Hi all,

I'm writing my dissertation using Lyx2.0 with the built-in thesis template.

The preamble in thesis template define
\renewcommand{\figureautorefname}{Fig.\negthinspace} to change the
default Figure to Fig. while referencing the figure. However, I found
out the it doesn't work for my me. Please find the attached file to
see the problem.

I've googled this problem for a while but couldn't find a solution.
Any suggestion would be more than welcome.

Thanks a lot!

Ruida
Richard Heck
2011-05-23 23:40:03 UTC
Permalink
Post by Ruida Yun
Hi all,
I'm writing my dissertation using Lyx2.0 with the built-in thesis template.
The preamble in thesis template define
\renewcommand{\figureautorefname}{Fig.\negthinspace} to change the
default Figure to Fig. while referencing the figure. However, I found
out the it doesn't work for my me. Please find the attached file to
see the problem.
I've googled this problem for a while but couldn't find a solution.
Any suggestion would be more than welcome.
I do not know for sure, but I would guess that this template is meant to
use the autoref features of hyperref. There is no direct support for
this in LyX. That is, you can do things like:
\autoref{fig:mylabel}
in ERT, but normal LyX cross-references will not be affected by the
command you mention.

Richard
Julien Rioux
2011-05-24 01:13:41 UTC
Permalink
Post by Ruida Yun
Hi all,
I'm writing my dissertation using Lyx2.0 with the built-in thesis template.
The preamble in thesis template define
\renewcommand{\figureautorefname}{Fig.\negthinspace} to change the
default Figure to Fig. while referencing the figure. However, I found
out the it doesn't work for my me. Please find the attached file to
see the problem.
I've googled this problem for a while but couldn't find a solution.
Any suggestion would be more than welcome.
Thanks a lot!
Ruida
This extract:
% increase link area for cross-references and autoname them
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}

from your preamble is an old trick to change the normal reference
format, which appear as "<reference>" in the cross-ref dialog of LyX,
into named references. Named references are now supported by LyX so it
is no longer necessary to use this trick. Simply use the "Formatted
reference" format in the cross-ref dialog. We should probably remove
this trick from places where it is used in LyX's docs and templates.

Named references are provided by one of these latex packages: either
prettyref or refstyle. This is configurable in the "Doucment class" options.

Using prettyref you can write in your preamble:
\newrefformat{fig}{Fig.~\ref{#1}}

If you are using hyperref and you want the "Fig." part to be clickable
also, instead use this:
\newrefformat{fig}{\hyperref[#1]{Fig.~\ref*{#1}}}

I do not know at the moment how to customize refstyle, but it should be
possible to do so in a similar way.
--
Julien
Richard Heck
2011-05-24 14:02:03 UTC
Permalink
Post by Julien Rioux
Post by Ruida Yun
Hi all,
I'm writing my dissertation using Lyx2.0 with the built-in thesis template.
The preamble in thesis template define
\renewcommand{\figureautorefname}{Fig.\negthinspace} to change the
default Figure to Fig. while referencing the figure. However, I found
out the it doesn't work for my me. Please find the attached file to
see the problem.
I've googled this problem for a while but couldn't find a solution.
Any suggestion would be more than welcome.
Thanks a lot!
Ruida
% increase link area for cross-references and autoname them
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}
from your preamble is an old trick to change the normal reference
format, which appear as "<reference>" in the cross-ref dialog of LyX,
into named references. Named references are now supported by LyX so it
is no longer necessary to use this trick. Simply use the "Formatted
reference" format in the cross-ref dialog. We should probably remove
this trick from places where it is used in LyX's docs and templates.
Named references are provided by one of these latex packages: either
prettyref or refstyle. This is configurable in the "Doucment class" options.
\newrefformat{fig}{Fig.~\ref{#1}}
If you are using hyperref and you want the "Fig." part to be clickable
\newrefformat{fig}{\hyperref[#1]{Fig.~\ref*{#1}}}
I do not know at the moment how to customize refstyle, but it should
be possible to do so in a similar way.
Refstyle supports figure-naming natively, so no new refformat needs to
be declared. By default, it gives "figure~\ref{#1}" (or whatever is
appropriate to the language). If you want to change this, then the easy
way is just to change the definition of \RSfigtxt, e.g.:
\def\RSfigtex{fig.~}
New reference formats can be defined as follows:
\newref{prop}{refcmd = {proposition \ref{#1}}
So prettyref's
\newrefformat{pfx}{...}
becomes:
\newref{pfx}{refcmd={...}}
This won't get you the range support, plurals and so forth, but LyX
doesn't yet support those anyway.

Note that you can also use \newref to redefine things refstyle defines
by default.

Richard
Uwe Stöhr
2011-07-26 23:23:00 UTC
Permalink
Post by Ruida Yun
I'm writing my dissertation using Lyx2.0 with the built-in thesis template.
The preamble in thesis template define
\renewcommand{\figureautorefname}{Fig.\negthinspace} to change the
default Figure to Fig. while referencing the figure. However, I found
out the it doesn't work for my me. Please find the attached file to
see the problem.
I cannot reproduce your problem. Attached is the PDF I get with your example file and as you can see
I get correctly the cross-reference named "Figure 1.1".

By the way, don't use numbers for the the labels. The numbers will most probably later change and
only lead to confusions. So better use a unique name.

regards Uwe

Loading...