Re: strange problem with arithmetics
- From: rf10@xxxxxxxxxxxx (Robin Fairbairns)
- Date: 30 May 2008 16:23:18 GMT
Victor Ivrii <vivrii@xxxxxxxxx> writes:
This works:
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{ifthen}
\usepackage{graphicx,color}
\newcommand{\test}[1]{%
\underline{\hskip#1in}
}
[...]
This does not (I plugged #1*0.7in instead of #1in).
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{ifthen}
\usepackage{graphicx,color}
\newcommand{\test}[1]{%
\underline{\hskip#1*0.7in}
}
[...]
How to fix it? I am more interested in something like
\usepackage{calc}
...
\newcommand{\test}[1]{%
\underline{\hspace{#1*0.7in}}%
}%
(note the correction of your use of %; and that the calc package will
operate on the argument of \hspace but not \hskip.
\newcolor{mycolor}{rgb}{0.03*#1, 0.5+0.0.1*#1,0.4-0.02*#1}
can't be done by the same technique; needs calculation of the values
as points in dimension registers, and then stripping the result as in
\edef\value{\expandafter\strip@pt\the\tempdimenreg}
so:
\usepackage{calc}
\newdimen\testdimen
...
\makeatletter
\newcommand\definecol[2]{% #1=factor, #2=name of colour to define
\setlength\testdimen{0.03pt*#1}%
\edef\@valuer{\expandafter\strip@pt\the\testdimen}%
...% analagously for green and blue
\newcolor{#2}{rgb}{\@valuer, \@valueg, \@valueb}%
}%
this can be done slightly more elegantly using \dimexpr, but i don't
have space in the margin to demonstrate that.
--
Robin Fairbairns, Cambridge
.
- Follow-Ups:
- Re: strange problem with arithmetics
- From: Morten Høgholm
- Re: strange problem with arithmetics
- From: Victor Ivrii
- Re: strange problem with arithmetics
- References:
- strange problem with arithmetics
- From: Victor Ivrii
- strange problem with arithmetics
- Prev by Date: Re: text overflows margins when going direct to PDF, otherwise not
- Next by Date: Re: hyperref link to longtable (in appendix) points to first page of document?
- Previous by thread: strange problem with arithmetics
- Next by thread: Re: strange problem with arithmetics
- Index(es):