Search code examples
maximawxmaxima

wxMaxima: how to use texput to tell tex1 how to handle strings?


tex1() seems to return all strings as follow:

tex1(hello);
    {\it hello}
tex1("hello");
    \mbox{ hello }

What variable must one use to change this handling via texput? e.g. if I would just like it to print strings literally? I'm using other Maxima commands (like printf and concat to produce strings that are then passed to tex1, and occasionally the default handling is causing issues.

I tried texput(""", ...) and texput("''", ...); the first wasn't accepted, the 2nd was, but did not change the output. I really have no clue for the non-quoted strings.


Solution

  • Let's be careful to distinguish symbols from strings. When you enter tex1(hello) then hello is a symbol, and when you enter tex1("hello") then "hello" is a string. Symbols are essentially names for items in a lookup table, which can store additional info (symbol properties) for each. Strings on the other hand are just (from Maxima's point of view) just a sequence of characters.

    Anyway changing the output for all symbols or all strings is unfortunately not possible via texput. But with a one-line Lisp function, one can accomplish it. Try this: for symbols,

    :lisp (defun tex-stripdollar (sym) (maybe-invert-string-case (symbol-name (stripdollar sym))))
    

    and for strings,

    :lisp (defun tex-string (str) str)
    

    These are going to change some existing outputs, so you'll want to try it and see if it works for you.