3

I use spreadtab with STcopy. For some reason, there is redundant whitespace at the left of the table. Here is a minimal working example:

\documentclass{standalone}
\usepackage{spreadtab}  
\begin{document}
\begin{spreadtab}{{tabular}{lll}}
\STcopy{>,v}{pow(1,1)}
& & 
\\
& & 
\\
& & 
\end{spreadtab}
\end{document}

In a "standalone" document, it is easy to see the extra space at the left. The extra space becomes larger when I add more rows.

Is this a bug?

1 Answers1

2

The problem is the same as in What makes my line get shifted to the left when I invoke \LoadConstants? and the solution again the same: add

\makeatletter
\def\FP@pow#1#2#3{% <---- This was unprotected
  % #1 macro, which gets the result
  % #2 base
  % #3 exponent
  %
  \FP@beginmessage{POW}%
  %
  {\def\FP@beginmessage##1{}%
   \def\FP@endmessage##1{}%
   %
   \FPifzero{#2}%
     \FP@pow@zero{#3}%
   \else%
     \FPln\FP@tmpd{#2}%
     \FPmul\FP@tmpd\FP@tmpd{#3}%
     \FPexp\FP@tmp\FP@tmpd%
   \fi%
   %
   \global\let\FP@tmp\FP@tmp%
  }%
  %
  \FP@endmessage{}%
  %
  \let#1\FP@tmp%
}
\makeatother

before \begin{document}.

Here's a four row spreadtab after the change:

\documentclass{standalone}
\usepackage{spreadtab}  

\makeatletter
\def\FP@pow#1#2#3{% <---- This was unprotected
  % #1 macro, which gets the result
  % #2 base
  % #3 exponent
  %
  \FP@beginmessage{POW}%
  %
  {\def\FP@beginmessage##1{}%
   \def\FP@endmessage##1{}%
   %
   \FPifzero{#2}%
     \FP@pow@zero{#3}%
   \else%
     \FPln\FP@tmpd{#2}%
     \FPmul\FP@tmpd\FP@tmpd{#3}%
     \FPexp\FP@tmp\FP@tmpd%
   \fi%
   %
   \global\let\FP@tmp\FP@tmp%
  }%
  %
  \FP@endmessage{}%
  %
  \let#1\FP@tmp%
}
\makeatother

\begin{document}
\begin{spreadtab}{{tabular}{lll}}
\STcopy{>,v}{pow(1,1)}
& &
\\
& &
\\
& &
\\
& &
\end{spreadtab}
\end{document}

enter image description here

Elementary, Watson.

How to find the source of the spurious spaces?

I added \tracingcommands=1 \tracingmacros=1 before \begin{spreadtabs} and run LaTeX. Then looked for {blank space} in the log file. Look and behold!

\FP@pow #1#2#3-> \FP@beginmessage {POW}{\def \FP@beginmessage ##1{}\def \FP@end
message ##1{}\FPifzero {#2}\FP@pow@zero {#3}\else \FPln \FP@tmpd {#2}\FPmul \FP
@tmpd \FP@tmpd {#3}\FPexp \FP@tmp \FP@tmpd \fi \global \let \FP@tmp \FP@tmp }\F
P@endmessage {}\let #1\FP@tmp 
#1<-\FP@valc 
#2<-\FP@vala 
#3<-\FP@valb 
{blank space  }

\FP@beginmessage #1->\ifFPmessages \message {( FP-#1}\fi 
#1<-POW
{begin-group character {}
{\def}
{\def}

The space was added in the middle of expanding \FP@pow. Where did I see that? Oh, yes! The old question I referenced. Problem solved.

Well, it's the same problem, so I made the answer “community wiki”. Otherwise some respected user could insinuate I get my rep just by chasing missing %.

egreg
  • 1,121,712