GeneralDefine Variable

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
pelle2005
Posts: 3
Joined: Fri Aug 01, 2008 11:59 am

Define Variable

Post by pelle2005 »

Hi to all,
someone say if it is possible to define a variable in latex and after that to use it in a if instruction?
I can't find information about this..
For example i would like to define a variable called "version" and use it to include a .tex file rather than another .tex file.
Thank you for the help

Recommended reading 2024:

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

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

T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

Define Variable

Post by T3. »

TeX does not have variables per se, and its if construct is also rather unusual. You could use something like this using macros and token comparison:

Code: Select all

\def\verA{1}
\def\verB{2}
\def\ver{1}
\ifx\ver\verA
%do something for version 1
\fi
\ifx\ver\verB
%do something for version 2
\fi
See also this and this thread.

Cheers,

Tomek
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Define Variable

Post by Stefan Kottwitz »

Hi,

the comment package provides a simple way with environments for different versions that can be excluded or included.

Stefan
LaTeX.org admin
Post Reply