I am trying to calculate some width in a macro and use the macro for scalebox. However I get a flood of errors when I try to pass the macro to scalebox.
MinimalExample:
\documentclass{article}
\usepackage{pgf}
\newcounter{Counter}
\setcounter{Counter}{1}
\newcommand{\testOk}{1}
\newcommand{\testFail}{
\theCounter
\stepcounter{Counter}
}
\setlength\parindent{0pt}
\begin{document}
\testFail %ok
\scalebox{\testFail}{a} %ok
\scalebox{\testFail}{a} %fails
\end{document}
Update
Since I want to actually use scalebox transparently in a new environment I decided to try something along the lines pointed at by Steven B. Segletes. Redefining the macro to do first the macroexpansion and then call the underlying macro with the value. I tried:
\newenvironment{imageRow}{
\begingroup\imageRow@reset
\LetLtxMacro{\oldScalebox}{\scalebox}
\renewcommand{\scalebox}[2]{
\edef\tmpValue{##1}
\oldScalebox{\tmpValue}{##2}
}
}{
\imageRow@complete\endgroup
}
However I keep getting 'missing endcsname' errors. (And a flood following that).
If it matters here is the function I am currently trying to pass as first argument:
\newcommand{\getIt}{%
\stepcounter{imageRow@getCount}%
%
\expandafter\ifx\csname imageRow@scale@Image@\theimageRow@rowCount @\alph{imageRow@getCount}\endcsname\relax
1%
\PackageWarning{imageRow}{Return to get correct scaling factors.}%
\else
\csname imageRow@scale@Image@\theimageRow@rowCount @\alph{imageRow@getCount}\endcsname\relax
\fi
}


\scaleboxneeds a number but you have passed it instructions to typeset a counter and then do some arithmetic to add 1 and assign that value to a counter, that is never going to work, you need to do the arithmetic fist then pass in the value. – David Carlisle Nov 05 '14 at 16:33scaleboxoradjustbox. I need csname for the retrival. – ted Nov 05 '14 at 16:40count@=#1which is fine if#1is a number but if you pass it\the\mycount\relax \advance\mycount by 1then it doesn't work. – David Carlisle Nov 05 '14 at 16:44\edefin your revised\scaleboxwill not remedy that. Therefore, you still end up passing operations to\oldscalebox. – Steven B. Segletes Nov 05 '14 at 20:31%from ends of lines, and if I understand you correctly you are passing tokens including\setcounterand\PackageWarninginto the first argument which will put them in an\edefthose commands can not possibly work in that context. The first argument of\scaleboxis already expanded by\scaleboxanything that you could put in an\edefcan be passed as the argument to\scaleboxso your redefinition does not do anything other than add spaces to the output. – David Carlisle Nov 05 '14 at 21:57\addImage{someCode}to add an image and\getScaleto get the factor by which the image should be scaled so that all pictures fill the row, and have equal height while keeping aspect ratios. I would like these two command soadjustboxscalboxortikzscalecan be used, depending on the situation. Take a look at https://github.com/coderinside/imageRow tp see what I got so far. – ted Nov 05 '14 at 23:53int func{return 2;}andint func{int i=getOneSomehow(); return i+1;}are equal in the outcome of the program. – ted Nov 06 '14 at 00:02%, I tried it out, the%is the minimum amount to have no extrawhitespace in the output. If I do\getIt\getItI get two numbers with no space in between, e.g.1.2349.034(notice the second decimal dot, with space it would be1.234 9.034) – ted Nov 06 '14 at 00:07