4
$\begingroup$

I am trying to get an expression to display correctly in TraditionalForm, with the negative sign in front of other symbols:

-Conjugate[Subscript["ϵ", "k"]] Subscript["Δ", "k"] // TraditionalForm //TeXForm

$\Delta _{\text{k}} \left(-\left(\epsilon _{\text{k}}\right){}^*\right)$

As you can see, the negative sign appears between the delta and epsilon, instead of appearing in front of both. It works as I expect if the delta is not subscripted.

-Conjugate[Subscript["ϵ", "k"]] "Δ" // TraditionalForm //TeXForm

$-\Delta \left(\epsilon _{\text{k}}\right){}^*$

Is there a way to force the negative sign to appear before the other symbols, even when using subscripted variables?

$\endgroup$
2
$\begingroup$

HoldForm command can prevent reshuffling of terms.

For example:

HoldForm[-Conjugate[Subscript["\[Epsilon]", "k"]] Subscript["\[CapitalDelta]", "k"]] // TraditionalForm

will result in:

$-(\epsilon_k)^* \Delta_k$

$\endgroup$
0
$\begingroup$

I think this probably should be considered a bug, but support may not agree. At any rate, if you don't mind mucking about with internal functions, you can fix this with the following patch:

TraditionalFormDump`ordtimes[Lb_, Lconst_] /; !TrueQ@$Fix := Block[{$Fix=True},
    If[negativeRowBox[Lb[[1]]],
        Prepend[1 + TraditionalFormDump`ordtimes[Rest @ Lb, Lconst], 1],
        TraditionalFormDump`ordtimes[Lb, Lconst]
    ]
]

negativeRowBox[{" ", rb_[{"-",__}]}] := StringStartsQ[SymbolName[rb], "myRowBox$"]
negativeRowBox[_] = False;

Then:

-Conjugate[Subscript["ϵ","k"]] Subscript["Δ","k"] //TraditionalForm //TeXForm

$-\left(\epsilon _{\text{k}}\right){}^* \Delta _{\text{k}}$

as desired.

$\endgroup$
0
$\begingroup$
- Conjugate[Subscript["ϵ", "k"]] Subscript["Δ", "k"] /. 
       Times[a_?Internal`SyntacticNegativeQ, b__] :> HoldForm[a Times[b]] // 
    TraditionalForm // TeXForm

$-\Delta _{\text{k}} \left(\epsilon _{\text{k}}\right){}^*$

$\endgroup$
1
  • $\begingroup$ This doesn't work so well with more multiplicands, e.g., -Conjugate[Subscript["ϵ", "k"]] Subscript["Δ", "k"] Subscript[x, k] $\endgroup$ – Carl Woll Oct 4 '18 at 16:13

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.