Tag Info

New answers tagged

2

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], ...


0

I believe it is because some upper-case letters are interpreted as functions K[x,y] //TraditionalForm (* $K[x,y]$ *) Note that K is a system name ?? K (* $K$ is a default generic name for a summation index in a symbolic sum. *) However, letters that are not functions are not: B[x,y] //TraditionalForm (* $B(x,y)$ *) All lower-case functions are ...


0

I do not think that you really need to create some special style. Why don you instead use the standard Grid function? For example, as follows: definitions = {{"Definition 1", "Bla-bla-bla1"}, {"Definition 2", "Bla-bla-bla2"}, {"Definition 3", "Bla-bla-bla3"}, {"Definition 4", "Bla-bla-bla4"}}; Grid[definitions] returning the following on the ...


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 ...


0

As you are typing, you can toggle between Code and Text styles using Alt+8 and Alt+7 (version 9.0.1.0 windows 8 x64) If the paragraph is already typed, you can highlight the part you want to change and use Alt+8 to change its style to Code. Or, you can use Format menu and select Code in the Style sub-menu. Alternatively, you can use Style[#,"Code"] to ...


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, ...


2

Update: You can also use GetCoordinates from the right-click menu: f[v_, t_] := 91.4 + (91.4 - t) (0.023 v - 0.304 Sqrt[v] - 0.474); ContourPlot[f[v, t], {v, 4, 45}, {t, -60, 30}, ContourLabels -> True] Use CoordinatesToolOptions to customize the content displayed: ContourPlot[f[v, t], {v, 4, 45}, {t, -60, 30}, ContourLabels -> True, ...


2

Manipulate[ Column@{Dynamic[MousePosition["Graphics", "Mouse not in graphics!"]], ContourPlot[91.4 + (91.4 - t) (0.023 v - 0.304 Sqrt[v] - 0.474), {v, 4, 45}, {t, -60, 30}, ContourLabels -> True]}, {{spot, {30, 15}}, {5, -60}, {45, 25}, Locator}]


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__] :> ...


3

Despite the command name, "Copy As LaTeX", Mathematica does not in fact have a feature (in the expected sense) for accomplishing this. Your expressions will be evaluated when creating the $\TeX$ representation. Your only recourse is to create a workaround that explicitly uses TeXForm to create $\TeX$ representation. For example, you can use TeXForm and the ...


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...


1

srF = StringReplacePart[#, ToString[Style[StringTake[#, {#2}], ##3], StandardForm], {#2, #2}] &; str = "CDABOZPVRYXSWQEGNILUTHMKJF"; srF[str, #, Red, Bold, 16] & /@ {3,9} Note: Copy as LateX does not work


1

just for fun..we can define a zfill function zfill[n_, f_String: "0"] := Function[{s}, StringJoin[ConstantArray[f, Max[0, n - StringLength[s]]], s]]; then the operation is quite similar to your python expression: zfill[2] /@ ToString /@ {-6, 1, 3, 23} {"-6", "01", "03", "23"}


3

This question is related to at least: Highlighting text with StringReplacePart but also using Style, Subscript How to join two Style[]d strings Fortunately it is simpler than the first one and we can apply the methods provided in the second one. stringBold[s_String, pos_] := "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, ...


3

ClearAll[nF] nF = With[{l = #, p = #2}, NumberForm[l, p, SignPadding -> True, NumberPadding -> {"0", ""}, NumberFormat -> (StringTake[#1, -(p + 1)] &)]] &; nF[{-6, 1, 3, 23}, 1] (* {-6, 01, 03, 23} *) nF[{-6, 1, 3, 23, 123}, 2] (* {-06, 001, 003, 023, 123} *) Note: You can also use PaddedForm instead of NumberForm.


3

Taking under consideration your assumptions: StringTake["0" <> ToString[#], -2] & /@ {-6, 1, 3, 23}


2

One way: If[StringLength@# == 1, "0" <> #, #] &@*ToString /@ {-6, 1, 3, 23} Another way: StringJoin@*(ToString /@ PadLeft[#, 2] &)@*Characters@*ToString /@ {-6, 1, 3, 23}


2

\I would suggest to use lower level formatting commands like this MakeBoxes[foo[arg1_Symbol, arg2_Symbol], StandardForm] := With[{arg1b = MakeBoxes[arg1], arg2b = MakeBoxes[arg2]}, TemplateBox[{arg1, arg2}, "foo", DisplayFunction :> (RowBox[{"(", RowBox[{arg1b, "\[CenterDot]", arg2b}], ")"}] &)]] a (x \[CenterDot] y) Using ...



Top 50 recent answers are included