I would like to request your help with the following: With the package hyperref I get a lot of backreferences in my bibliography like 1,1,1,2,2,3,5,8,9,10,11,11,11,12,12,13,17,19 Now I wanted to write a macro that turns this result into: 1-3,5,8-13,17,19 if Kind = 0 1,3;2,2;3;5;8;9;10;11,3;12,2;13;17;19 if Kind = 1 where Kind is a variable to have a certain layout according to your choice When I run the file PROBEERTEST.TEX the above examples are correct but the bottom one has a lot of 'I assume spaces' in front of it (I have tried adding % after each line and removing all spaces but I still get those spaces). Can anyone help me (I want that the aa is followed immediately by the result and not with this free room after it)
FILE PROBEER.TEX *
% To turn 1,1,1,2,2,3,5,8,9,10,11,11,11,12,12,13,17,19 into % 1-3,5,8-13,17,19 if Kind = 0 % To turn 1,1,1,2,2,3,5,8,9,10,11,11,11,12,12,13,17,19 into % 1,3;2,2;3;5;8;9;10;11,3;12,2;13;17;19 if Kind = 1 % Based on TeX by Topic p 105 \newcount\Kind % 0: like 1--3,5,7,10--12, % 1: like 1,2;3,2;number,# of number; \newcount\CountP % Previous \newcount\CountN % Next \newcount\CountT % Temp \newcount\CTimes % Number of times \newcount\State % 3: using kind=1 after reading in % first element (state=2) % 2: start, first element printed % 1: during {--}. % 0: otherwise (non-sequential) \CountP=-10000 \CTimes=0 \Kind=0 % --- begin TO STORE THE RESULT \def\ResultDef{} % def to hold the result % USING DEF TO STORE THE RESULT \def\addToResultDef#1{ \edef\ResultDef{\ResultDef #1} } \def\printResultDef{ \ResultDef } % --- end TO STORE THE RESULT \def\Combine#1{\xCombine#1,xxx, \printResultDef \CountP=-10000 \CTimes=0 \def\ResultDef{} } \def\endpiece{xxx} \def\xCombine#1,{\def\temp{#1} \ifx\temp\endpiece \advance \CountN by 3 % to process the last element \Process{\the\CountN} \else \Process{#1} \expandafter \xCombine \fi} \def\Process#1{ \CountN=#1 \ifnum\CountP=-10000 \CountP=\CountN \State=2 \advance \CTimes by 1 %\the\CountP \addToResultDef{\the\CountP} \else \ifnum\CountP=\CountN \advance \CTimes by 1 \else % \CountP<\CountN \ifnum\Kind=0 \ProcessA{#1} \else \ProcessB{#1} \fi \CTimes=1 \CountP=\CountN \fi \fi } \def\ProcessA#1{ % \Kind=0 \CountT=\CountP \advance\CountT by 1 \ifnum\CountN=\CountT \ifnum\State=0 %\the\CountP \addToResultDef{,\the\CountP} \fi \State=1 \else \ifnum\State=0 %, \the\CountP \addToResultDef{,\the\CountP} \else \ifnum\State=1 %{--} \the\CountP \addToResultDef{{--}\the\CountP} \State=0 \else \ifnum\State=2 \State=0 \else \typeout{Invalid State!!} \fi \fi \fi \fi } \def\ProcessB#1{ % \Kind=1 \ifnum\State=2 \ifnum\CTimes=1 \else \addToResultDef{,\the\CTimes} \fi \State=3 \else % State=3 \ifnum\CTimes=1 \addToResultDef{;\the\CountP} \else \addToResultDef{;\the\CountP,\the\CTimes} \fi \fi }FILE PROBEERTEST.TEX *
%% To test probeer.tex in TeX itself to see if it works accordonly \magnification\magstep1 \hsize 5.5 true in \hoffset 0.5 true in \vsize 8.25 true in \voffset = 2\baselineskip \vbadness11000 \input probeer \noindent 1,1,1,2,3,4,5,6,7,11,12,13,15,17 \hfill \break becomes \hfill \break \Combine{1,1,1,2,3,4,5,6,7,11,12,13,15,17} \hfill \break \hfill \noindent New attempt: \hfill \break 1,2,3,4,5,6,7,11,12,12,13,15,17,17,21,22,23 \hfill \break becomes \hfill \break \Combine{1,2,3,4,5,6,7,11,12,12,13,15,17,17,21,22,23} \hfill \break \hfill \vbox{ \hbox to \hsize{1,2,3,4,5,5,6,7,11,12,13,15,17,21,22,23 \hfill} \hbox to \hsize {becomes \hfill} \hbox to \hsize{aa\Combine{1,2,3,4,5,5,6,7,11,12,13,15,17,21,22,23}bb \hfill} \vfill} \bye
