LyX has amazing support for cross-referencing, but I can't figure out how to reference something by its label in the output (pdf) instead of a number only.
For example, I have many formulas/equations in a math book I'm writing. When I write an equation, I can assign a label to it. Lyx will also assign a number to the equation. Later if I want to reference the equation, I can do something like:
...see Ref:eq:Distance Formula.
So I have no problem referencing the equation. However, in the pdf output, this will show up as something like:
...see 213.
Of course, I can insert an "eq" before the number. But what I really want is:
...see Distance Formula.
This is a lot more informative than just a number, and in the pdf (like a e-book) this reference can be made clickable so the reader can immediately go to the formula if he wants to. I might also want the text to be formatted in a special way (bold,italic etc).
Your advice will be appreciated.
LyX ⇒ How to reference an equation by label in my final output?
-
- Posts: 3
- Joined: Sun Nov 11, 2012 8:04 pm
NEW: TikZ book now 40% off at Amazon.com for a short time.

-
- Site Moderator
- Posts: 542
- Joined: Sat Sep 01, 2012 6:38 am
Re: How to reference an equation by label in my final output
Why not just write "See Distance Equation"?
You can add the following ERT command in ERT:
\renewcommand{\ref}[1]{\emph{#1}}
This is not a good solution because this will change *all* of your references, not just the equation references. But is something like this what you have in mind for equations? If so, we can come up with a better solution that is only for equations. See the attached .lyx file.
Scott
You can add the following ERT command in ERT:
\renewcommand{\ref}[1]{\emph{#1}}
This is not a good solution because this will change *all* of your references, not just the equation references. But is something like this what you have in mind for equations? If so, we can come up with a better solution that is only for equations. See the attached .lyx file.
Scott
- Attachments
-
- changeRef.lyx
- (1.6 KiB) Downloaded 352 times
-
- Posts: 3
- Joined: Sun Nov 11, 2012 8:04 pm
Re: How to reference an equation by label in my final output
Thank you. Yes I want it for equations only. So I guess I can change it to something like Ref:eq. But I want the format to be defined across the entire book, could you please show me how to do that?
Another important thing for me is that I want the reference to be clickable in the final pdf output after I enable hyperef support. I tried your .lyx and the reference isn't clickable. Is there a way to enable this?
Again thank you so much for your help.
Another important thing for me is that I want the reference to be clickable in the final pdf output after I enable hyperef support. I tried your .lyx and the reference isn't clickable. Is there a way to enable this?
Again thank you so much for your help.
-
- Site Moderator
- Posts: 542
- Joined: Sat Sep 01, 2012 6:38 am
How to reference an equation by label in my final output?
Ah so this is why you still want to use the \ref command.letslearnmath66 wrote:Thank you. Yes I want it for equations only. So I guess I can change it to something like Ref:eq. But I want the format to be defined across the entire book, could you please show me how to do that?
Another important thing for me is that I want the reference to be clickable in the final pdf output after I enable hyperef support. I tried your .lyx and the reference isn't clickable. Is there a way to enable this?
I think that without packages, LaTeX does not know whether you are referencing a figure, a table, or an equation, etc. A hackish solution is to rely on the label name. This is LyX's solution (which rely's on prettyref or refstyle and depends on the "Eq" prefix in the label). A better solution is to use the cleveref package. But this depends on your workflow (are all of your equations prefixed with "Eq" ?). Read the manuals of those three packages and you might find something that helps.
Scott