Tag Info

Hot answers tagged

16

To prevent this from happening, you may be able to make use of the new-in-8 keyboard shortcut EscketEsc, and similarly for the other symbols, EscbraEsc, EscbraketEsc. These shortcuts bring up a template which is already delimited appropriately. After entering this, you have to press Tab to get "teleported" into the placeholder where the contents of the ket ...


15

You could do it using the following (this is the first version of the answer; don't use it if you want the more complete solution below): SetOptions[EvaluationNotebook[],InputAliases->{"bn"-> FormBox[TemplateBox[{"\[SelectionPlaceholder]", "\[Placeholder]"},"Binomial"],InputForm]}] Then enter escbnesc to get a placeholder that you can tab ...


12

Your are in computational mode, when Mathematica cares that you do not have any corresponding bra. It seems to me that you do not really care for computation and a reasonable thing would be to got to a typesetting realm. Then what about entering things as strings? I used palettes to type it, but the code for this is: ...


12

I don't know if it qualifies as an answer to your question if I suggest to change the structure of the labeling in the first place. As you write it, the m is -- from the rendering point of view -- treated as a symbol, if you inclose it with quotation marks it will be treated as a string and no auto-italic is performed at all. E.g.: PlotLabel -> "Test ...


11

Here is the formatting command that does this: pvB /: MakeBoxes[pvB[n1_, n2_, x_, s_, m0_, m1_], TraditionalForm] := RowBox[{SubscriptBox["B", RowBox[{Sequence @@ Riffle[Table["0", {n1}], "\[ThinSpace]"], "\[ThinSpace]", Sequence @@ Riffle[Table["1", {n2 - n1}], "\[ThinSpace]"]}]], "(", Sequence @@ Riffle[Map[ToBoxes, {x, s, m0, ...


10

It's in the style sheet. Use a custom style sheet to override the default. Format > Edit Stylesheet... then enter style name: TraditionalForm Open Format > Option Inspector... and set SingleLetterItalics to False


10

This is a nice exercise on boxing: MakeBoxes[u[v_[r_[b_]]], TraditionalForm] := Module[{b1, b2, b3, t}, t = ToBoxes[#, TraditionalForm] &; {bl1, bl2, bl3} = StyleBox[#1, #2] & @@@ { {"{", {20, Orange}}, {"[", {15, Purple}}, {"(", {12, Blue}}}; {br1, br2, br3} = {bl1, bl2, bl3} /. {"[" -> "]", "{" -> "}", "(" -> ")"}; ...


6

Answer inspired by this : Style[Grid[{{TraditionalForm[ Defer[1/Pi = 2*Sum[((-1)^k*(6*k)!*(13591409 + 545140134*k))/((3*k)!* k!^3*640320^(3*k + 3/2)), {k, 0, 44}]]]}}], UnderoverscriptBoxOptions -> {LimitsPositioning -> False}] gives : EDIT Rojo's solution (see comments) is better because it doesn't reduce the sigma : ...


6

As Daniel Lichtblau wrote in the comment you can use TraditionalForm Expand[(x^2 - 1) ((-3 + x)^2 - 4)] // TraditionalForm $x^4-6 x^3+4 x^2+6 x-5$ However, it works perfectly only with univariate polynomials Expand[(x + y + 1)^5] // TraditionalForm $x^5+5 x^4 y+5 x^4+10 x^3 y^2+20 x^3 y+10 x^3+10 x^2 y^3+30 x^2 y^2+30 x^2 y+10 x^2+5 x y^4+20 x ...


4

The key option here is LimitsPositioning. This is an option of UnderoverscriptBox and related boxes which determines how under and overscripts of "∑", "∏", "⋂", "⋃", "⊎", "⋀", "⋁", "lim", "max", "min", "⊕", "⊖", "⊗", "⊙" behave when displayed in a display formula or an inlined equation. You can set them in Mathematica typesetting (box) language, but it can ...


4

The correct attribute to set would be HoldAll, but modifying built-in functions like this (setting attributes that affect evaluation) is very likely to break things. Instead, use HoldForm: TraditionalForm@HoldForm[(17.517*CuS^2 - 12.081*CuS + 54.875)/(1.121)]


4

You can try using Format along with Inactive First, need to Unprotect NonCommutativeMultiply: Unprotect[NonCommutativeMultiply]; Format[NonCommutativeMultiply[x__], TraditionalForm] := Inactive[Times][x] This will look like: NonCommutativeMultiply[a, c + d, c] // TraditionalForm $a*(c+d)*c$ which is not quite right yet. For the finishing touches we ...


4

Manipulate[ToExpression[func, TraditionalForm] /. x -> val, {{val, Pi, "x"}, InputField}, {{func, "", "f(x)"}, InputField[##, String] &}]


3

You can write a function that processes the boxforms produced by TraditionalForm to replace the parentheses by square brackets: tF=RawBoxes[ToBoxes[TraditionalForm[#]]/.{"("->"[",")"->"]"}]&; TraditionalForm/@{C[x,y], Sin[x], f[x,y], H[x], h[x,y,z], H[x,y], h[{x,y}]} (* {C[x,y], sin(x), f(x,y), H(x), h(x,y,z), H(x,y), h({x,y})} *) tF/@{C[x,y], ...


3

I might be oversimplifying something but I believe you can use: MakeBoxes[pvB[n_, P_, _, x__], fmt : TraditionalForm] := MakeBoxes[#, fmt] & @ Subscript[Defer @ B, Row[1 ~Table~ {n} ~PadLeft~ P]][x] pvB[2, 4, x, s, m0, m1] // TraditionalForm


3

Here's an alternate way to format it using Format: Format[pvB[n_, P_, x_, s_, m0_, m1_], TraditionalForm] := DisplayForm@RowBox[{ SubscriptBox["B", StringJoin@SparseArray[{i_ :> "1" /; i > P - n}, P, "0"]], RowBox[{ "(", Sequence @@ Riffle[ToBoxes /@ {s, m0, m1}, ","], ")" }] }] This definition will be saved in the FormatValues for pvB.


3

You need to use BoxData. Because ToString creates something strange you also obviously have to change "\\" -> "". I don't know if this is a bug or working as designed. equat = (StringReplace[ToString[#1, TraditionalForm], "\\" -> ""] & )[ Expand[ Product[x - RandomInteger[{-10, 10}], {i, 3 + RandomInteger[]}]]]; CellPrint[ ...


3

Let us inspect the built-in behavior ToBoxes@TraditionalForm[f[a, b]] (* TagBox[FormBox[RowBox[{"f", "(", RowBox[{"a", ",", "b"}], ")"}], TraditionalForm], TraditionalForm, Editable -> True] *) So myfuncF /: MakeBoxes[myfuncF[a_, b_], TraditionalForm] := RowBox[{"f", "(", RowBox@Riffle[Map[ToBoxes, {a, b}], ","], ")"}] x myfuncF[a, b] // ...


2

myfuncF /: MakeBoxes[myfuncF[a_, b_], TraditionalForm] := RowBox[{"f", "(", RowBox[{ToString@a, ",", ToString@b}], ")"}] x myfuncF[a, b] // TraditionalForm myfuncF[a, b] > 0 // TraditionalForm


2

Jens's answer provides a good idea, but for some users (with v7 or older versions), "ket", "bra" and "braket" are not built-in Mathematica input aliases. To define these aliases in Mathematica, one may execute the following code: SetOptions[$FrontEnd, InputAliases -> Join[{"ket" -> TemplateBox[{"\[Placeholder]"}, "Ket", ...


2

First of all, I don't see any need for the Notation package here. So I'll just omit that. Also, you need to replace -> by :> in the definition for c, otherwise a may be polluted by a global value. The rest can be done as follows: (*Creates a subscripted integer*) fock[n_Integer, m_] := Subscript[n, m] (*Creates a series of 0's indexed from 1 to nm*) ...


2

res = TraditionalForm[ HoldForm[Subscript[W, f[a, b]][ c] == \[Rho]^f[a, b] \[Omega][c] \[Rho]^-f[a, b]]]; res /. {c -> 7, f[a, b] -> 5}; For your second question you can try this: g[a_,b_]:=a Sin[b]; res /. {c -> 7, f[a, b] -> g[2 , 3]}


2

ls = HoldForm[Subscript[W, f[a, b]][c] = ρ^f[a, b] ω[c] ρ^-f[a, b]] ReplaceRepeated[ls, {f[a, b] -> 5, c -> 7}] Then just TraditionalForm that...


2

Crucial, for answer to this question, is: why parts of our expression should "stay unevaluated". = in Mathematica is Set function. If we want to express assignment, but just don't want to evaluate it, then we can use = and HoldForm like in rasher's answer, or, if we just want to suppress Set evaluation, we can Inactivate it: Inactivate[Subscript[W, f[a, ...


1

Since you want Mathematica to perform some simplifications of your expression, I don't think this is purely formatting question. Inferring from your desired simplifications of $\rho^i\omega\rho^{-i}$ for different $i$, it is supposed to be some form of multiplication, but different than built-in Times function. I would start with defining desired ...


1

formatter[fab_, c_] := Block[{p1, p2, lhs, rhs, fn}, rhs = If[fab == 0, Subscript[\[Omega], c], If[fab < 0, fn = Abs[fab]; HoldForm[\[Rho]^-f Subscript[\[Omega], c] \[Rho]^f] /. f -> fn, HoldForm[\[Rho]^fab Subscript[\[Omega], c] \[Rho]^-fab]]]; lhs = Subscript[W, fab][c]; Replace[Evaluate[{lhs, rhs}], List[a__, b__] :> ...


1

PrettyPoint /: MakeBoxes[PrettyPoint[e___], TraditionalForm] := With[{mb = MakeBoxes[#, TraditionalForm] & /@ {e}}, RowBox[{"(", Sequence @@ Riffle[mb, ","], ")"}] ] PrettyPoint[Log[x/y], Log[1 + y/x]] // TraditionalForm


1

MatrixForm[{Log[x/y], ",", Log[1 + y/x]}, TableDirections->Row, TableSpacing->0.3] // TraditionalForm The spacing around the comma is not perfect but the parentheses look good.


1

All the comments notwithstanding, I think there may be an acceptable compromise between notational simplicity and formal accuracy. It involves defining functions really as Function, not by patterns. Here is an example of how that looks in TraditionalForm. It's the replacement for the standard definition a[x_]:= Sin[x], now written in a notation that you'll ...


1

A problem with the given solutions exists at least in version 7.0.1 on Win7, (but not in version 8), in that a space is added to a string when Inset is used. Starting with the default format this text appears in italics, with an extra space: ab = Graphics[{{Yellow, Rectangle[{0, 0}, {1, 0.5}]}, Inset["A&B", {0.5, 0.25}]}, AspectRatio -> 0.5, ...



Only top voted, non community-wiki answers of a minimum length are eligible