I recently started using LyX for some articles that I'm writing. I think I have a pretty decent handle on the basic functions after 10+ hours. Anyway, I was thinking that one thing that crops up a lot is that I might say something like:
U.S. GDP growth is expected to be 10%.
And then I refer to the 10% again multiple times throughout a document
I tried to use LyX to create a label like [U.S.-GDP-growth] and then cross-reference to [Ref: U.S.-GDP-growth]. But it doesn't produce the text 10% in other sentences. It's just blank.
I take this to mean that you can't label or cross-reference to some generic text. Is my understanding correct? It seems like a simple thing to change.
More generally, I may want to create a master document with individual words. numbers, phrases, sentences, whole paragraphs, parts of equations, or whole equations that are meant to be repeated in key places. Rather than update them multiple times throughout the document, I would rather do them in one place and then refer to them many times throughout the document.
Presuming I didn't pass up some amazing feature, anyone know how to pass this along to developers?
LyX ⇒ Cross-Reference generic Text
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Cross-Reference generic Text
Hi,
welcome to the board!
Simply define macros in your preamble, or in a file such as macros.tex and load it within your LyX document preamble by
Your macro.tex could look like:
Stefan
welcome to the board!
Simply define macros in your preamble, or in a file such as macros.tex and load it within your LyX document preamble by
Code: Select all
\input{macros}
Code: Select all
\newcommand*{\USGDPgrowth}{10\%}
\newcommand*{\phrase}{A long phrase}
...
LaTeX.org admin
Re: Cross-Reference generic Text
Thanks!. I will try this (I had not quite gotten to doing macros in Lyx). It looks like it will be useful.
Edit: I tried it and was having some difficulties. I exported the a LyX file with the commands to a .tex file. In the second file, I inserted that macros code as TeX, which seemed to work, but couldn't seem to figure out how to get the references to show up.
Edit: I tried it and was having some difficulties. I exported the a LyX file with the commands to a .tex file. In the second file, I inserted that macros code as TeX, which seemed to work, but couldn't seem to figure out how to get the references to show up.
Re: Cross-Reference generic Text
I realized what wasn't work when I first was trying this. I was creating a .tex file by typing that text in LyX and exporting to a LaTeX(plain) format. Instead, I just created a .txt file copied that text in and saved it as .tex. Apparently the LyX exported was adding some code that prevented it from compiling.