Sorry, I skimmed the TeXbook for an hour but couldn't find how to do simple calculations in TeX... This is a snippet from t-lilypond.tex: \def\LPscale{0.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily! figures.pdf][]% % \def\FigWidth{\LPscale\figurewidth} \leavevmode \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi \externalfigure[\lily!img][scale=1000\LPscale]% \egroup% I need to downscale every score to 63%, and the shown width check should use the corrected width. How can I do that? (FigWidth should be LPscale * figurewidth) Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
Henning Hraban Ramm wrote:
Sorry, I skimmed the TeXbook for an hour but couldn't find how to do simple calculations in TeX...
This is a snippet from t-lilypond.tex:
\def\LPscale{0.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily! figures.pdf][]% % \def\FigWidth{\LPscale\figurewidth} \leavevmode \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi \externalfigure[\lily!img][scale=1000\LPscale]%
does sx=\LPscale work? ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Tue, 19 Sep 2006 22:53:18 +0200, Henning Hraban Ramm
I need to downscale every score to 63%, and the shown width check should use the corrected width. How can I do that? (FigWidth should be LPscale * figurewidth)
I don't know what you really want to do, but an example of computation could look like this: \newdimen\myfigwidth \newdimen\myfigurewidth \def\myscale{.63} \figurewidth=23pt \myfigwidth=\dimexpr(\myscale\myfigurewidth) \starttext \the\myfigwidth \stoptext Regards, BG
Am 2006-09-19 um 23:34 schrieb nico:
I need to downscale every score to 63%, and the shown width check should use the corrected width. How can I do that? (FigWidth should be LPscale * figurewidth)
I don't know what you really want to do, but an example of computation could look like this:
\newdimen\myfigwidth \newdimen\myfigurewidth \def\myscale{.63}
\figurewidth=23pt \myfigwidth=\dimexpr(\myscale\myfigurewidth)
\starttext \the\myfigwidth \stoptext
Thank you, but now I always get: ! Illegal unit of measure (pt inserted). <to be read again> . \figurewidth ->545. 03625pt \dodostartlilypond ...expr (\LPscale \figurewidth ) \ifdim \FigWidth
\localh...
from the code: \def\LPscale{.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily! figures.pdf][]% \leavevmode% \newdimen\FigWidth \FigWidth=\dimexpr(\LPscale\figurewidth) \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi \externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]% \egroup% What's wrong with \dimexpr{\SomeDef\SomeDim} ? Some expansion problem? (Sorry, I only try to patch the code, I didn't write it.) Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
On Wed, 20 Sep 2006 00:04:33 +0200, Henning Hraban Ramm
Thank you, but now I always get:
! Illegal unit of measure (pt inserted). <to be read again> . \figurewidth ->545. 03625pt \dodostartlilypond ...expr (\LPscale \figurewidth ) \ifdim \FigWidth
\localh...
\figurewidth is not a dimension. I guess the following should work: \def\LPscale{.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily!figures.pdf][]% \leavevmode% \newdimen\FigWidth \newdimen\FigWidthReal=\figurewidth \FigWidth=\dimexpr(\LPscale\FigWidthReal) \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi \externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]% Regards, BG
Am 2006-09-20 um 00:40 schrieb nico:
\figurewidth is not a dimension. I guess the following should work:
\def\LPscale{.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily!figures.pdf][]% \leavevmode% \newdimen\FigWidth \newdimen\FigWidthReal=\figurewidth \FigWidth=\dimexpr(\LPscale\FigWidthReal) \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi
Thank you very much, that works indeed.
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
But here \dimexpr is nonsense (should have seen that before). But "scale=1000\LPscale" just concatenates the two "strings", and TeX doesn't seem to reckognize a * How can I multiply two values? Di I need some expansion magick or just something like "eval()"? Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
Henning Hraban Ramm wrote:
Am 2006-09-20 um 00:40 schrieb nico:
\figurewidth is not a dimension. I guess the following should work:
\def\LPscale{.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily!figures.pdf][]% \leavevmode% \newdimen\FigWidth \newdimen\FigWidthReal=\figurewidth \FigWidth=\dimexpr(\LPscale\FigWidthReal) \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi
Thank you very much, that works indeed.
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
But here \dimexpr is nonsense (should have seen that before). But "scale=1000\LPscale" just concatenates the two "strings", and TeX doesn't seem to reckognize a *
\def\LPscale{.6315789pt} scale=\withoutpt\the\dimexpr\LPscale*1000\relax Vit
How can I multiply two values? Di I need some expansion magick or just something like "eval()"?
Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- ======================================================= Ing. Vít Zýka, Ph.D. TYPOkvítek database publishing databazove publikovani data maintaining and typesetting in typographic quality priprava dat a jejich sazba v typograficke kvalite tel.: (+420) 777 198 189 www: http://typokvitek.com =======================================================
Henning Hraban Ramm wrote:
Am 2006-09-20 um 00:40 schrieb nico:
\figurewidth is not a dimension. I guess the following should work:
\def\LPscale{.6315789} % downscale the image \ifvmode \getfiguredimensions[\bufferprefix lilypond-\the\lily!figures.pdf][]% \leavevmode% \newdimen\FigWidth \newdimen\FigWidthReal=\figurewidth \FigWidth=\dimexpr(\LPscale\FigWidthReal) \ifdim\FigWidth>\localhsize \!!dimena=\localhsize \advance\!!dimena by-\FigWidth \noindent\hskip\!!dimena \fi \fi
Thank you very much, that works indeed.
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
But here \dimexpr is nonsense (should have seen that before). But "scale=1000\LPscale" just concatenates the two "strings", and TeX doesn't seem to reckognize a *
How can I multiply two values? Di I need some expansion magick or just something like "eval()"?
\numexpr should work here ..[scale=\numexpr1000\LPscale\relax]% Greetings, Peter
Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Am 2006-09-21 um 21:12 schrieb Peter Rolf:
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
\numexpr should work here ..[scale=\numexpr1000\LPscale\relax]%
thank you, that seemed what I looked for, but: ! You can't use `\numexpr' in horizontal mode. BTW, Hans' hint "sx=\LPscale" doesn't seem to do anything. Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
Henning Hraban Ramm wrote:
Am 2006-09-21 um 21:12 schrieb Peter Rolf:
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
\numexpr should work here ..[scale=\numexpr1000\LPscale\relax]%
thank you, that seemed what I looked for, but: ! You can't use `\numexpr' in horizontal mode.
One of my favourite errors. Everytime it occurs I'm a bit puzzled, as I've no general solution for this. I can only tell you what I do in such a case. - check every parameter of the expression If the expression itself is ok - check the correct grouping of prior commands (boxes, conditionals,..) - try to calculate the expression before you pass it \newcount\Myscale \Myscale\numexpr1000\LPscale\relax ..[scale=\the\Myscale] But in the end it is more try and error than a systematic action. If there is a more general approach to solve this, I would be happy to hear it. Greetings, Peter
BTW, Hans' hint "sx=\LPscale" doesn't seem to do anything.
Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Peter Rolf wrote:
Henning Hraban Ramm wrote:
Am 2006-09-21 um 21:12 schrieb Peter Rolf:
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
\numexpr should work here ..[scale=\numexpr1000\LPscale\relax]%
thank you, that seemed what I looked for, but: ! You can't use `\numexpr' in horizontal mode.
One of my favourite errors. Everytime it occurs I'm a bit puzzled, as I've no general solution for this. I can only tell you what I do in such a case.
- check every parameter of the expression
If the expression itself is ok
- check the correct grouping of prior commands (boxes, conditionals,..) - try to calculate the expression before you pass it \newcount\Myscale \Myscale\numexpr1000\LPscale\relax ..[scale=\the\Myscale]
But in the end it is more try and error than a systematic action. If there is a more general approach to solve this, I would be happy to hear it.
Gr some day soon:
\def\integer#1{\lua{tex.sprint(math.floor(#1))} scale=\integer{1000*\LPscale} Hans -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 2006-09-25 um 11:46 schrieb Peter Rolf:
\externalfigure[\lily!img][scale=\dimexpr(1000\LPscale)]%
\numexpr should work here ..[scale=\numexpr1000\LPscale\relax]%
thank you, that seemed what I looked for, but: ! You can't use `\numexpr' in horizontal mode.
One of my favourite errors. Everytime it occurs I'm a bit puzzled, as I've no general solution for this. I can only tell you what I do in such a case. - check every parameter of the expression If the expression itself is ok - check the correct grouping of prior commands (boxes, conditionals,..) - try to calculate the expression before you pass it \newcount\Myscale \Myscale\numexpr1000\LPscale\relax ..[scale=\the\Myscale] But in the end it is more try and error than a systematic action. If there is a more general approach to solve this, I would be happy to hear it.
I think I tried everything but didn't get it to work. For the moment I use: \def\LPscale{0.6315789} % downscale the image \def\LPkscale{632} % doesn't work: \def\LPkscale{\numexpr1000\LPscale\relax} But anyway - my problem is caused by LilyPond not obeying its size commands in EPS mode, so the simple scaling doesn't help... Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
Hi, Henning Hraban Ramm wrote:
I think I tried everything but didn't get it to work. For the moment I use: \def\LPscale{0.6315789} % downscale the image \def\LPkscale{632} % doesn't work: \def\LPkscale{\numexpr1000\LPscale\relax}
Missed this thread so far, but how about this? \edef\LPkscale{\the\numexpr1000\LPscale\relax} Cheers, Taco
Am 2006-09-26 um 08:53 schrieb Taco Hoekwater:
I think I tried everything but didn't get it to work. For the moment I use: \def\LPscale{0.6315789} % downscale the image \def\LPkscale{632} % doesn't work: \def\LPkscale{\numexpr1000\LPscale\relax}
Missed this thread so far, but how about this? \edef\LPkscale{\the\numexpr1000\LPscale\relax}
Thank you. That doesn't run on an error, but scales way too much. With \def\LPscale{0.6315789} the command should have the same effect as \def\LPkscale{632} But \edef\LPkscale{\the\numexpr1000\LPscale\relax} seems to scale about 100 times too much. I simply(?!?) want to multiply some floating point value with 1000 to set the "scale" parameter of \externalfigure. Why ist this so difficult? Is there a book or tutorial on TeX as a programming language somewhere? Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
Hi Hraban, Henning Hraban Ramm wrote:
Am 2006-09-26 um 08:53 schrieb Taco Hoekwater:
I think I tried everything but didn't get it to work. For the moment I use: \def\LPscale{0.6315789} % downscale the image \def\LPkscale{632} % doesn't work: \def\LPkscale{\numexpr1000\LPscale\relax} Missed this thread so far, but how about this? \edef\LPkscale{\the\numexpr1000\LPscale\relax}
Thank you. That doesn't run on an error, but scales way too much. With \def\LPscale{0.6315789} the command should have the same effect as \def\LPkscale{632}
But \edef\LPkscale{\the\numexpr1000\LPscale\relax} seems to scale about 100 times too much.
maybe \numexpr1000\dimexpr\LPscale\relax\relax I have a good feeling about it ;)
I simply(?!?) want to multiply some floating point value with 1000 to set the "scale" parameter of \externalfigure. Why ist this so difficult?
Because there is no normal float type in TeX like in common programming languages. Also all calculation is limited by \maxdimen.
Is there a book or tutorial on TeX as a programming language somewhere?
I like 'Tex by Topic' alot. Don't know if that fits your needs. http://archive.contextgarden.net/message/20060901.140544.1fe86b32.en.html Greetings, Peter
Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://contextgarden.net http://www.cacert.org (I'm an assurer)
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Peter Rolf wrote:
I like 'Tex by Topic' alot. Don't know if that fits your needs.
http://archive.contextgarden.net/message/20060901.140544.1fe86b32.en.html
that ons is ok (apart from a buggy index) and i use that most of the time it also helps to have the tex book around the advanced tex book is also ok but rather plain tex Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (6)
-
Hans Hagen
-
Henning Hraban Ramm
-
nico
-
Peter Rolf
-
Taco Hoekwater
-
Vit Zyka