# Tag Info

## Hot answers tagged output-formatting

7

Add this to your notebook or init file $PrePrint = If[MatrixQ[#], MatrixForm[#], #] &; Then all matrices will automatically display as MatrixForm and If you want to format lists as column vectors also, try$PrePrint = Which[MatrixQ[#], MatrixForm[#], VectorQ[#], ColumnForm[#], True, #] &; Now also

3

For the example problem, you know 1+10^(-n) will have exactly n digits after the decimal, or n+1 digits precision, so you can do: Table[N[1 + 10^(-n), n + 1], {n, 1, 30}] 1.1 , 1.01 , 1.001 , .... 1.000000000000000000000000000001 The example in the comment is something like this: h[t_] = 58 t - 83/100 t^2; Table[With[{t = 1 + 10^(-n) }, N[ ...

3

Here's one possible way of doing this. Type some text into 2 successive text cells, then select the cell brackets, open the option inspector (Format / Option Inspector ...) and alter the values displayed at Cell Options / Display Options / CellMargins. For instance, if the 2 text items are "Hello" and "World", then the resulting Cell expressions might be ...

3

Let me through a first version into the room: SetAttributes[echo, HoldAll]; echo[x___] := StringRiffle[{##}, ", "] & @@ Function[arg, ToString[Unevaluated[arg], InputForm], {HoldFirst}] /@ Hold[x]; Now you get Print[TemplateApply["><", echo[2^2, "foo", 2 + 2, None]]] (* >2^2, "foo", 2 + 2, None< *) Be aware that you might ...

3

Slightly more handy approach (unless you want to work with negative integers): Grid[ {#, "+", #2, "=", Item["", ItemSize -> 3]} & @@@ RandomInteger[20, {10, 2}] , Alignment -> {{Right, Center, Right, Center, Center}}, BaseStyle -> {Italic, 20}, Frame -> True, Background -> {{}, {{GrayLevel@.9, GrayLevel@.95}}} ] A simplistic ...

3

You could try something like the following: Table[dS[i] = -β[i]*S[i], {i, 4}]; To see the definitions for dS use the function Definition. Definition[dS] (* dS[1]=-S[1] β[1] dS[2]=-S[2] β[2] dS[3]=-S[3] β[3] dS[4]=-S[4] β[4] *) See that you can perform operations on dS. dS[1] + dS[2] (* -S[1] β[1] - S[2] β[2] *)

2

The purpose of using HoldForm and Plus is to allow automatic formatting rules for Plus to apply while preventing evaluation. Since you want custom formatting rules that method may be inapplicable. To get alignment we can either use a tabular format like Grid (as Kuba did) or we can pad the numbers themselves. One automatic approach to the latter is ...

2

Since you did not include your data, I am generating some fake data to play with: fakedata = Transpose@ Insert[ Transpose@ Insert[ RandomReal[{0, 1}, {6, 50}], Array["y lbl " <> ToString@# &, 50], 1 ], {""}~Join~Array["x lbl " <> ToString@# &, 6], 1 ]; The code first generates a 6-row by ...

2

You could import each frame of your movie as a separate image, then use ListAnimate on this list to generate an animation on which you would then have full control. I am going to generate a static image and a test movie to play with: staticimage = Rasterize@Plot[Sin[x], {x, -Pi, Pi}, AspectRatio -> 1, ImageSize -> Medium]; Table[Rasterize@Plot[Sin[i ...

2

As @kattern pointed out, MatrixForm will pretty print your lists to look like matrices. {{0}, {1}, {0}, {-1}} // MatrixForm A word of caution, however: MatrixForm can get in the way of your calculations if you are not careful. See this question and the related answers: Why does MatrixForm affect calculations?. For instance, you could get bitten by ...

1

booleanTable := Module[ {var, iter}, f = Input["Enter Boolean function"]; var = BooleanVariables@f; iter = Sequence @@ ({#, {True, False}} & /@ var); Column[{Table[ Evaluate[{var, f} // Flatten], Evaluate[iter]] // Flatten[#, Length[var] - 1] & // Prepend[#, {var, f} // Flatten] & // ...

1

I know I have answered a very similar question before but I can't find it now. Of what I can find my own question How can I get the unchanged Box form of an arbitrary expression? is probably closest, though more recently Why aren't parentheses ( ) an expression in Mathematica? maybe closer in application to what you need. For pursuing your goal it is ...

1

I'm running V10.1 on OS X 10.10.2 (Yosemite). There may be a problem on OS X. On all versions of OS X prior to Yosemite the system font was Lucida Grande. On Yosemite it is Helvetica Neue. So I tried both. ButtonLabelStyle[x_] := Style[x, 9, FontFamily -> "Helvetica Neue"] Button["//ContractBasis" // ButtonLabelStyle, Null, ImageSize -> 85] ...

1

Using the function SparseArrayExpressionToTree: ClearAll[trF] trF[s_: {0.01, .05}][e_, opts : OptionsPattern[Options[Graph]]] := Module[{saett = SparseArrayExpressionToTree[e], edges, vertices, vsizes, labels, vlabels}, edges = saett[[All, All, 2]]; vertices = DeleteDuplicates[Join @@ List @@@ edges]; labels = ArrayPad[Replace[saett[[All, ...

1

Second update (2015-05-11): Amandeep, you recently left a comment with the following expression: xpr = a1*D11*Cos[n*x] + a0*a1*D11*Cos[n*x] + 1/2*a1*a3*D11*Cos[n*x] + 1/2*a2*a4*D11*Cos[n*x] + a2*a3*a4*Sin[n*x] I believe that you may have left out a multiplication sign on the argument of the last Sin function. Once we add that back in, the approach using ...

1

I think you want Row: Subscript[a, Row@{b, b}] abb Consider also Indexed but beware that it is not an inert (formatting) function. Indexed[a, {b, b}] abb

1

list = {"b", "c", "d"}; Subscript[a, list[[1]] <> list[[1]]] // TraditionalForm or list = {b, c, d}; Subscript[a, ToString[list[[1]]] <> ToString[list[[1]]]] // TraditionalForm

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