Graphics, Figures & Tableshow to assign a value to a variable

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
steem84
Posts: 9
Joined: Fri Dec 18, 2009 2:09 pm

how to assign a value to a variable

Post by steem84 »

Hello,

I am a newbe in Latex and I'm wondering how to assign a value to a variable. This could then be useful to give every figure a constant figure width, for example. This is what I am trying to do


\newcommand{\figurewidth}{0.9\textwidth}

% and then later, in the figure enviroment

\begin{figure}
\includegraphics[width=\figurewidth]{dog}
\end{figure}


unfortunately integers do not work with \newcommand. How to do this?


Steven

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

how to assign a value to a variable

Post by frabjous »

Just use \newlength{\figurewidth} and then \setlength{\figurewidth}{0.9\textwidth}.

See LaTeX lengths.
steem84
Posts: 9
Joined: Fri Dec 18, 2009 2:09 pm

Re: how to assign a value to a variable

Post by steem84 »

That does the job. Thanks!
Post Reply