GeneralCreate a value to be cross-referenced

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
dadrivr
Posts: 8
Joined: Sat Sep 11, 2010 3:49 pm

Create a value to be cross-referenced

Post by dadrivr »

Hi all,

I am new to LaTeX, and was wondering if it's possible to create a value to be cross-referenced. For example, I would like to create a variable ("sample") that holds a number for the sample size (e.g., 70), and to be able to reference that value throughout the paper by calling the variable and not having to manually change the value in all places. Is this possible? Thanks so much!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Create a value to be cross-referenced

Post by frabjous »

Well, it may depend on exactly how you want to use this "variable", but for most purposes, a custom command should do the trick:

Code: Select all

\newcommand*{\sample}{70}
Now, \sample will be replaced by "70" wherever it occurs. If you want to change it everywhere, you need to only edit the one line.

If you want something you can use as a length, etc., there may be better options, but we don't have quite enough information on what you plan on doing with this.
Post Reply