3

I would like to be able to change the way Maxima generates the LaTeX code (in general). For example, I have the following code in Maxima:

enter image description here

I then exported the code to LaTeX, and I immediately get an error saying:

! Package inputenc Error: Unicode char \u8:− not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.

You can check out the LaTeX code generated through this gist on GitHub.

I would like at least not only to not get any errors, but also to change a little bit the style of the LaTeX code generation to adapt it to certain circumstances. For example, I would like to be able to insert a break line (or more) after the outputs...

Is it possible to do? Are there any alternatives?

nbro
  • 15,395
  • 32
  • 113
  • 196

3 Answers3

3

You can put the following line in the preamble of the LaTeX output:

\DeclareUnicodeCharacter{2212}{-}

which tells LaTeX what to do with the Unicode hyphen (character 2212 according to this table).

WxMaxima should generate this declaration itself -- it is a bug that it does not.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • I have inserted it, now I have the following error: `! Missing $ inserted.$` , but I fixed it by removing a line break from `\begin{math}\displaystyle \parbox{8ex}{\color{labelcolor}(\%o2) } \end{math}`. – nbro May 21 '15 at 20:05
  • Another error: `! Package inputenc Error: Unicode char \u8:¦ not set up for use with LaTeX.See the inputenc package documentation for explanation.Type H for immediate help.... \end{verbatim}`, which I fixed by removing the following character `¦` from `\begin{verbatim} ¦ \end{verbatim}}`... – nbro May 21 '15 at 20:09
  • Anyway, it seems there are a lot of bugs in `wxMaxima`, at least when generating LaTeX code.. – nbro May 21 '15 at 20:11
  • I don't see the vertical pipe symbol in gistfile1.txt. Did you export the file again? Can you post the revised file? – Robert Dodier May 21 '15 at 20:13
  • Here you have the new [gist](https://gist.github.com/dossan/1f8018864e155229a5f4). – nbro May 21 '15 at 20:24
  • Hey, I have noticed that I have no more the error of the vertical pipe... What a crazy situation..but I still have the one of the unwanted line break – nbro May 21 '15 at 20:25
  • Maybe try `wxplot2d(...) $` (i.e. terminate with dollar sign to suppress output for that line). Just guessing that will fix the problem with the "missing $ inserted". – Robert Dodier May 21 '15 at 21:07
  • The problem of the missing statement `\DeclareUnicodeCharacter{2212}{-}` seems to fixed in more recent versions of `wxMaxima`, according to some contributor from GitHub... I had opened a issue there... – nbro May 21 '15 at 21:24
  • Man, actually replacing `;` with `$` made the tex compile without problems! Strange... – nbro May 21 '15 at 21:26
  • 1
    About `wxplot2d(...)$`, I think wxplot2d returns an empty string, so there is an empty line in the TeX output. Looks like that empty line causes the error. Putting a dollar sign tells wxMaxima not to try to generate an output line. That seems like a bug in wxMaxima -- it shouldn't generate TeX output which causes an error. – Robert Dodier May 21 '15 at 21:49
  • Ok, thanks for the explanation. I hope they fixed also this in the last versions of wxMaxima. Maybe I should report also this error. By the way, if you can, consider to change the way Maxima generates the LaTeX code (introducing the template file that can be changed and adapted by the users), because it would be very helpful. Thank You!! – nbro May 21 '15 at 21:52
  • I agree that a template file is a good idea, but the TeX preamble is generate by wxMaxima code, not Maxima. Maybe you can suggest it to them. – Robert Dodier May 21 '15 at 22:07
1

Most likely something happened when you exported the code. To fix the existing file you can follow the accepted answer to this question.

https://tex.stackexchange.com/questions/83440/inputenc-error-unicode-char-u8-not-set-up-for-use-with-latex

But try exporting again and see if the error was accidental.

Update:

Add

\DeclareUnicodeCharacter{00A0}{ }

to your preamble.

Community
  • 1
  • 1
soegaard
  • 30,661
  • 4
  • 57
  • 106
1

Well, the gistfile1.txt at line 54 contains characters instead of -. I wonder how those characters were generated. What commands did you enter in wxMaxima to generate gistfile1.txt?

Anyway, I find that if I replace those characters with ordinary hyphens, it avoids the error you reported. So perhaps the problem is to avoid generating those characters in the first place.

EDIT: This answer is off the mark. See my other answer for a real solution.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • Do you know any way to change the template file to generate LaTeX documents from the Maxima ones? – nbro May 21 '15 at 14:15
  • After looking at this again, I see it's a bug in wxMaxima, which is generating a Unicode character in the output but not including the required `\DeclareUnicodeCharacter` for it. My advice is to report the bug to the wxMaxima bug tracker -- you can find the info for it via Help >> Bug Report. About the LaTeX template, it appears that there is no template file -- the LaTeX preamble is generated from hard-coded print statements in the source code. See src/MathCtrl.cpp in the wxMaxima source code. – Robert Dodier May 21 '15 at 19:20
  • Ok. Since you are a programmer/mantainer of Maxima, would not be possible for next releases to change the way LaTeX code is generated, maybe introducing a template file that anyone can change depending on the needs? This would really improve maxima, because I think it's a really powerful tool for computations, but some stuff simply does not work well.. – nbro May 21 '15 at 19:26
  • WxMaxima is maintained as a separate project from Maxima -- Maxima is the back end and wxMaxima is the front end. You'll need to submit this request to the wxMaxima project. I'm sorry for the confusion. – Robert Dodier May 21 '15 at 19:36