9
$\begingroup$

I have several expressions for which I need the LaTex output. If I put them one after another with TeXForm, only the last one is shown (see picture).

This is different to for example "TraditionalForm" behavior which prints all three inputs. Am I missing something or the behavior of TeXForm and TraditionalForm (or actually any other *Form) is simply different? I can circumvent it by appending \\Print after \\TeXForm, but it is not always desired (namely, having each output in a different cell allows to refer to that as %number; either form can be saved to a variable, but it would be best if the behaviour was the same for both cases).

enter image description here enter image description here

$\endgroup$
5
  • $\begingroup$ This happens with version 10: Which version are you using? $\endgroup$
    – mattiav27
    Commented Mar 1, 2017 at 9:45
  • $\begingroup$ 11.0.1, but this existed for as long as I remember. $\endgroup$
    – user37523
    Commented Mar 1, 2017 at 13:36
  • $\begingroup$ Similar: mathematica.stackexchange.com/questions/126189/… $\endgroup$
    – masterxilo
    Commented Mar 9, 2017 at 21:50
  • $\begingroup$ Indeed the issue almost certainly has the same root cause. Especially given Szabolcs answer $\endgroup$
    – user37523
    Commented Mar 10, 2017 at 13:41
  • $\begingroup$ Did you ask Wolfram about this? If yes, what did they say? Is it by design or a bug? $\endgroup$
    – Szabolcs
    Commented Jan 24, 2018 at 11:18

2 Answers 2

9
$\begingroup$

This is just a long comment.

I see the same behaviour in several versions between 9.0–11.0.

Looking at what is actually being sent to the FE with LinkSnooper, we see that the kernel does send all results back, however, the front end only displays the last one. Based on a few experiments, it seems that:

  • When the result is sent as a ReturnExpressionPacket (i.e. it comes as boxes: StandardForm, TraditionalForm, FullForm, etc.) or ReturnTextPacket (OutputForm), then all results are displayed.
  • When the result is sent as ReturnInputFormPacket (InputForm, TeXForm, CForm, etc.), then only the last result is displayed.

I would report this behaviour to Wolfram Support.

As a workaround you can do this (which I think is a better approach anyway):

TeXForm /@ {Sqrt[1 + x^2 + x^4], Sqrt[1 + x^2 + x^5], Sqrt[1 + x^2 + x^6]}
$\endgroup$
0
4
$\begingroup$

Another workaround is to tack on an "invisible" wrapper such as SequenceForm:

Sqrt[1 + x^2 + x^4] //TeXForm //Defer
Sqrt[1 + x^2 + x^5] //TeXForm //SequenceForm
Sqrt[1 + x^2 + x^6] //TeXForm //HoldForm

$\sqrt{x^4+x^2+1}$

$\sqrt{x^5+x^2+1}$

$\sqrt{x^6+x^2+1}$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.