Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a rather complicated multifile document built around probsoln. Everything works fine until I introduce a template for division which works fine everywhere else:

\newdimen\digitwidth \settowidth\digitwidth{0}
\def~{\hspace{\digitwidth}}
\def\divrule#1#2{%
\noalign{\moveright#1\digitwidth%
\vbox{\hrule width#2\digitwidth}}} 
%This is the divisor
            $+3x$
            $-1$
                \hspace{0mm}
        \begin{tabular}[b]{@{}l@{}} 
%This is the quotient 
                \hspace{2mm}
            $+2x^{2}$
                \hspace{2mm}
            $+3x$
                \hspace{6mm}
            $+1$
                \hspace{5mm}
            $-2x^{-1}$
                \hspace{2mm}
            $+[...]$
                \hspace{2mm}
            \\ 
            \hline
        \big)
        \begin{tabular}[t]{@{}l@{}l@{}}
%This is the dividend (Its length controls the line.)
            $+6x^{3}$ 
                \hspace{5mm}
            $+7x^{2}$ 
                \hspace{10mm}
%           $+x$ 
                \hspace{15mm}
            $-7$
        \\ 
%This is the first product
                \hspace{-17.5mm}
            {\footnotesize Ominus:}
                \hspace{1mm}
            $+6x^{3}$ 
                \hspace{5mm}
            $-2x^{2}$ 
           \\ %origin,length
           \divrule{0}{33}
%This is the first remainder
                \hspace{15mm}
            $+9x^{2}$ 
                \hspace{13mm}
%           $+4x$ 
                \hspace{12mm}
            $-7$
           \\ 
%%This is the second product
            {\footnotesize Ominus:}
                \hspace{2mm}
            $+9x^{2}$ 
                \hspace{7mm}
            $-3x$ 
           \\ 
           \divrule{8}{25}%origin,length
%%This is the second remainder
                \hspace{35mm}
            $+3x$ 
                \hspace{8mm}
            $-7$
           \\ 
%This is the third product
                \hspace{13mm}
            {\footnotesize Ominus:}
%               \hspace{3mm}
            $ $ 
                \hspace{6mm}
            $+3x$ 
                \hspace{8mm}
            $-1$ 
                \hspace{5mm}
           \\ 
           \divrule{17}{17}%origin,length
%This is the third remainder
                \hspace{15mm}
            $ $ 
                \hspace{10mm}
            $ $ 
                \hspace{12mm}
            $ $ 
                \hspace{8mm}
            $-6$
           \end{tabular}
           \end{tabular}

I then get the following error:

    ../QuestionsBase/16/27.tex:439: Illegal parameter number in definition of \@tmp
.
<to be read again> 
                   1
l.439 }

Now, if I tell the console to keep going, I get the same error message but with a 2. The third gets me the same but with a 1 again. The fourth gets me the same with a 2 again and the fifth compiles fine.

The problem seems to be the way the division interacts with the code derived from probsoln and so I am fully aware that this is not something that can be solved ex cathedra and I am not looking for that. My questions are: Based on the above, what kind of things that I should be looking for? Is there a reference where I could learn what to look for? Hopeful regards --schremmer

share|improve this question

1 Answer 1

a few basic tools (as used to answer any question on this site:-)

0) Believe the error message and look at line 439 of your file:-)

1) eyeball for common mistakes.

2) add \tracingall

or there is;

3) do nothing and hope egreg answers

for 1

Most dangerous code is

\def~{\hspace{\digitwidth}}

There is probably a lot of code assuming that ~ has its usual definition.

there are loads of missing % although none that would obviously cause an error \hspace{0mm} for example adds two word spaces to the output rather than a space of zero width as the newline before and after are not commented out (and not merged to one).

For the specific case of Illegal parameter number in definition of \@tmp most usual cause is a missing } somewhere that makes a #2 in a later definition be seen as part of teh definition of \@tmp which should have been finished earlier.

for 2

\tracingall output can be quite large (you might prefer instead just \tracingmacros=2) But if the same top level command works in one place but not in another, some command used internally in the definition has a different definition. So add \tracingall just before the command and let it run to the error then stop by typing x to the prompt. then do the same on the good file. then compare the two log files (emacs ediff or any other diff tool comes in useful here) at some point the good and bad executions must diverge and that shows you which command has a different definition.

share|improve this answer
    
@ Carlisle (1) \tracingall gives "Illegal parameter number in definition of \@tmp" –  schremmer Dec 19 '13 at 1:24
    
@schremmer yes of course it does, tracing doesn't change the errors, just shows what tex was doing at the time. The point is to compare a log file from the file without the error and see where tex started to take a different path, which will before the error. Some macro must have expanded differently. –  David Carlisle Dec 19 '13 at 11:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.