5

So I've decided to clean my code for the many plots.

I've basically taken out all the plot data into separate files using

\def\plotname{
x1    y1
}

Then I use \input{data.txt} to load all the plotting data at once and then

\begin{NumericDataPlot}{\textwidth}{6cm}
\newpsstyle{MyLineB}{linecolor=blue, linestyle=none,showpoints=true,dotsize=1pt}
\listplot[style=MyLineB]{\plotname}
\end{NumericDataPlot}

So far, so good. Most plots work as expected. However it turns out there is some issue with some \def names.

For instance, using \muIPS leads to the following error

! Use of \muIPS doesn't match its definition.\addto@pscode ...ef \pst@code {\pst@code #1\space} \listplot[style=MyLineB]{\muIPS}

But when I change the name to \muips it compiles just fine.

So to sum up, LaTeX seems to be very idiosyncratic about the def name it allows. Please note that the names were working fine before I used nested input files...

EDITED FOR EXPLANATION :

One of the other names was \def\muIPS-U and it wasn't used.

So when I changed to \muips, it had no confusion about the definition to use. Turns out, you can't use - character in the defname? What other characters are forbidden?

  • Without a complete example it's difficult to say something. What's the definition of \muIPS? – egreg Mar 13 '13 at 22:51
  • Like I said it's very hard to make a small working example but it always works until I nest the calls of some 15 files. \def\muIPS { 1 -110 2 -109.25 3 .... ... ~15000 -0.0002 } So some 15k coordinates. This is not about downsampling the plot because it can actually display it when I change the name How can I attach zip file? – user26488 Mar 14 '13 at 15:09
  • This will break the Latex... \documentclass[9pt]{beamer} \usepackage{etex} \usepackage{NumericPlots} \begin{document} % WORKS \frame{ \frametitle{TEST} \input{plot-gamma} } %% COPY DEF CONTENT TO DATA FILE %% AND \begin{NUMERICPLOT} TO OTHER FILE %% --> ERROR DEF \input{Data.txt} \frame{ \frametitle{TEST} \input{plot-mu-ind} } \end{document} – user26488 Mar 14 '13 at 15:23
  • Please, supplement the question with the code. – egreg Mar 14 '13 at 15:24
  • \def\muIPS-U is not possible in this way. Use only characters or \csname muIPS-U\endcsname. – user2478 Mar 14 '13 at 15:54
5

To answer your edited question you can use any character in a csname so

\csname MUIPS-U\endcsname

is OK and constructs the token with name MUIPS-U however when parsing the input stream after the escape character (usually \) TeX only accepts multiple character sequences if all the characters are of catcode 11 (letter) so by default a-z and A-Z.

If you go

\def\muIPS-U{a}

That is legal but defines \muIPS such that it must be followed by -U and then expands to a. If it isn't followed be -U you get the error:

! Use of \muIPS doesn't match its definition.

However you can use

\@namedef{muIPS-U}{a}

which defines the token with name muIPS-U to expand to a. You can access that token via

\@nameuse{muIPS-U}

\@namedef and \@nameuse are LaTeX utilities but you often see the equivalent primitive syntax versions:

\expandafter\def\csname muIPS-U\endcsname

and

\csname muIPS-U\endcsname
0

To supplement David Carlisle's answer with a comment based on a guess: most likely, your code contained the definitions in the following order:

\def\muIPS{...}
\def\muIPS-U{...}

Since TeX interprets the -U as "delimiting text" that is not part of the macro name, the second \def actually redefines \muIPS to be a delimited macro. Then, later, when you use \muIPS in your document, TeX looks unsuccessfully for the required -U and gives you that error.

When you switch to using \muips for the first one, it is no longer redefined and so you no longer get the error. There is still a definition of \muIPS floating around, still requiring -U after it, but with \muIPS no longer in use there is no conflict, and using \muIPIS-U works by accident, since it has the required form even though TeX interprets the name differently than you do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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