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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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