Tag Info

Hot answers tagged

25

The power of Mathematica's syntax allows us to create a dice in several different ways. Here's one way that I like: dice[n_Integer] := dice[n, Black] Format[dice[n_Integer, c_]] := With[{ dots = {1 -> {5}, 2 -> {3, 7}, 3 -> {3, 5, 7}, 4 -> {1, 3, 7, 9}, 5 -> {1, 3, 5, 7, 9}, 6 -> {1, 2, 3, 7, 8, 9}} /. l : ...


20

We have unicode support so we can use the following strings: {"⚀", "⚁", "⚂", "⚃", "⚄", "⚅"}: dice = FromCharacterCode /@ Range[9856, 9856 + 5]; Grid[Partition[RandomInteger[{1, 6}, {50, 2}], 5] /. { i : {__Integer} :> Style[ Row[dice[[i]], Spacer[1]], {Large, Total[i] /. {7 -> Red, _ -> Black}}]} , Frame -> All]


16

After importing a free dice 3D model {pd, vd} = Import["c:\\dice.stl", #] & /@ {"PolygonData", "VertexData"}; g2 = Translate[GraphicsComplex[vd, Polygon /@ pd], {-10, -37.5, -10}]; rv = {{0, 0, -1}, {0, -1, 0}, {0, 0, 1}, {0, 1, 0}, {-1, 0, 0}, {1, 0, 0}}; dice[x_List, n_Integer] := Rasterize@(Graphics3D[{EdgeForm[None], Blue, Rotate[g2,{{0, 0, ...


16

Declaration: This method for Windows is based on the .NET code from Todd Gayley's this wonderful answer. My .NET knowledge is absolutely ZERO, all credit goes to Todd. Code: The main idea is to extract the "Input"-style code string, convert it to the UTF-16 little endian form, which is the standard byte order in Windows, feed the bytes to system clipboard ...


12

Typesetting in Text cells Cell[TextData[Cell[BoxData[ FormBox[ RowBox[{ FractionBox["1", "N"], RowBox[{ UnderoverscriptBox["\[Sum]", RowBox[{"i", "=", "1"}], "N"], FractionBox[ RowBox[{ SubsuperscriptBox[ OverscriptBox["x","~"], "j", "i"], "(", RowBox[{"k", "|", "k"}], ")"}], SqrtBox[ ...


12

You can always write your own version of PeriodicForm: ClearAll@PeriodicForm PeriodicForm[n_] := RealDigits[n] /. {{d___Integer, {i__Integer} ...}, l_Integer} :> PeriodicForm[n, l, {d}, {i}] Format[PeriodicForm[n_, l_, d_, i_]] ^:= Interpretation[Row[{ FromDigits[d ~Take~ l] /. {} -> 0, ".", Sequence @@ d ~Drop~ l, ...


11

A reliable approach would use the third argument of Reduce as variables to eliminate (see Behavior of Reduce with variables as domain) Reduce[{p == a b x + b^2 y + a c z, a b == 1, b^2 == 2, a c == 4}, {p}, {a, b, c}] p == x + 2 y + 4 z In the former editions of Mathematica (ver <= 4) Reduce used the third argument for eliminating another ...


10

Using the same (well slightly modified) Wolfram demonstrations code as bill s dicelist = {{Disk[{0, 0}, 0.2]}, {Disk[{0.6, 0.6}, 0.2], Disk[{-0.6, -0.6}, 0.2]}, {Disk[{0, 0}, 0.2], Disk[{0.6, 0.6}, 0.2], Disk[{-0.6, -0.6}, 0.2]}, {Disk[{0.6, 0.6}, 0.2], Disk[{-0.6, -0.6}, 0.2], Disk[{0.6, -0.6}, 0.2], Disk[{-0.6, 0.6}, 0.2]}, ...


10

You can often get tolerable results from the likes of GraphicsColumn by specifying explicit values for ImagePadding, making sure you allow enough padding for frame or axis labels. Here's a stacked plot using GraphicsColumn: commonopts = {Mesh -> None, InterpolationOrder -> 0, PlotRange -> All, PlotStyle -> Thick, Frame -> True, Axes ...


10

ToCCodeString has the "Indent" option, which defaults to None. Set it to the number of tabs you want for an indentation, and you should be fine.


10

Caveat: Since this uses hidden, undocumented functions, it will probably break at some point in the future. Also, I do not have any knowledge of how these functions work, except guesses from observed behavior. Some information is available via Information. Under the hood of TexForm is Convert`TeX`ExpressionToTeX, which in turn calls Convert`TeX`BoxesToTeX ...


9

Another dice: dots = {{{2, 2}}, {{0.85`, 0.85`}, {3.15`, 3.15`}}, {{0.85`, 0.85`}, {2, 2}, {3.15`, 3.15`}}, {{0.85`, 3.15`}, {0.85`, 0.85`}, {3.15`, 3.15`}, {3.15`, 0.85`}}, {{0.85`, 3.15`}, {0.85`, 0.85`}, {2, 2}, {3.15`, 3.15`}, {3.15`, 0.85`}}, {{0.85`, 3.15`}, {0.85`, 0.85`}, {3.15`, 3.15`}, {3.15`, 0.85`}, {0.85`, 2}, {3.15`, 2}}}; ...


9

Here's one way, borrowing heavily from one of the Wolfram demonstrations. dicelist[rb_] := {{rb, Disk[{0, 0}, 0.2]}, {rb, Disk[{0.6, 0.6}, 0.2], Disk[{-0.6, -0.6}, 0.2]}, {rb, Disk[{0, 0}, 0.2], Disk[{0.6, 0.6}, 0.2], Disk[{-0.6, -0.6}, 0.2]}, {rb, Disk[{0.6, 0.6}, 0.2], Disk[{-0.6, -0.6}, 0.2], Disk[{0.6, -0.6}, 0.2], Disk[{-0.6, 0.6}, 0.2]}, {rb, Disk[{0, ...


9

Update It's probably easier to use Edit -> Copy As -> Bitmap from the menubar. Changing the magnification of the notebook will change the size of the image that gets sent to the clipboard Previous answer There's likely a better answer out there, but I use a hack of the SEUploader to do this. toclipboard2[] := If[ MemberQ[Hold[{}, $Failed, ...


9

Another approach: mark[s_, where_] := With[{n = ToString@s}, Row@{StringDrop[n, -where], Style[StringTake[n, -where], Red]}] Let's say you want to mark last 3 digits: mark[N[Pi, 45], 3] And a little bit more general approach: mark[s_, w_] := With[{n = ToString@s}, Row@MapAt[Style[#, Bold, Red] &, ...


8

In my opinion, GraphicsRow is no good. Neither is GraphicsGrid or GraphicsColumn. I can't remember all the reasons right now, but I stopped using them a couple years ago and now exclusively use Grid. When I do Grid[{{plot1, plot2}}] I get which I think is what you want.


8

The answer You create metafiles every time when you copy graphics from Mathematica FrontEnd and paste it in MS Word because it is native format for exchanging vector graphics under Windows. So your question is actually about corrupted metafiles in MS Word document opened on a machine without Mathematica fonts installed. This behavior is expected because ...


8

Here is a very robust (!!) method expr = (z14 z43 (z01 + z03 + z12 + z32) + z01 z12 z43 + z03 z14 z32); StringReplace[ToString[expr, TeXForm], " " :> "\\times"] Using Ctrl+Shift+C to copy as plain text results in ...


8

John Fultz alluded to using the Villegas-Gayley pattern. Since I believe that is the correct approach to this problem here is an implementation. mk : MakeBoxes[(Hold | HoldForm | HoldComplete | HoldPattern)[__], _] := Block[{$hldGfx = True, Graphics, Graphics3D}, mk] /; ! TrueQ[$hldGfx] I included HoldPattern to complete the Hold functions. This now ...


8

Looks like StringForm can achieve this: Cp = 1.5; deltastar = 0.123; Then: StringForm["The value for `1` is `2` and the value for `3` is `4`.", HoldForm @ Subscript[C, p], Cp, HoldForm @ Superscript[\[Delta], "*"], deltastar]


8

The following may be useful as starters: WolframAlpha["femme from french to german",{{"Translation:TranslationData", 1}, "ComputableData"}] (* {" Frau | Ehefrau", " Frau"} *)


7

x = E^-n (2 E^-1 + E^2) + E^n (2 E^-2 + E); x /. Times[a_, b_] :> Times[a, ExpToTrig@b] E^n (E + 2 Cosh[2] - 2 Sinh[2]) + E^-n (2 Cosh[1] + Cosh[2] - 2 Sinh[1] + Sinh[2])


7

To get PeriodicForm working in Mathematica 9 (and probably other versions after 6) you need to first download the obsolete package from the Wolfram Library Archive. Run the package, ignore the errors and have fun: Get["http://library.wolfram.com/infocenter/MathSource/6773/\ ContinuedFractions.m?file_id=6182"] PeriodicForm[RealDigits[19/7]]


7

Right, it doesn't work, but you can use this alternative: Grid[{{"The Thick Red Frame"}}, Frame -> True, FrameStyle -> Directive[Red, Thickness@10]]


7

Because Inactivate acts on Heads of expressions, replaces them with Inactive[h] where h is the Head of the expression and prevents them from evaluating. And in your case the Head of x y is Times: FullForm[x y] Times[x, y] So Inactivate[x y] Gives: Where the Times did not evaluate. Hence, the result you get when you apply TraditionalForm.


7

It sounds like you're merely looking for Row: Cp = 1.5; deltastar = 0.123; Row[{ "The value for ", HoldForm[Subscript[C, p]], " is ", Cp, " and the value for ", HoldForm[Superscript[\[Delta], "*"]], " is ", deltastar, "." }] If this does not work for you please clearly state how it fails so that those issues can be directly addressed.


7

Part a response, Because you do not show additional information and do not describe the problem with the code, I show one approach. First we construct some helpers : ClearAll["Global`*"] SetDirectory@NotebookDirectory[]; siz1 = 250; siz2 = 500; tex1 = "What a long and interesting and certainly necessary title for \ a panel of functions."; title = ...


6

When I posted this question, I said I wouldn't post my answer if someone else posted an equivalent one, but here I am doing it. Am I going back on my word?. The answer given by ssch is close enough to mine to qualify as equivalent for all practical purposes. However, although both our answers are based on the same insight: that no graphics are needed because ...


6

I am rather aghast at how poor those solutions are! Are the two sets of data suppose to be related? They have the same horizontal range so why not put them on top of each other and have only one x axis? Then it is really poor technique to use an Axis plot when the data is crossing the axis. The ticks and labels clobber the data! Look in a journal such as ...


6

See last paragraph in Scope:- http://reference.wolfram.com/mathematica/ref/ExponentFunction.html nFormat = NumberForm[#, {\[Infinity], 2}, NumberPoint -> ",", NumberSeparator -> ".", DigitBlock -> 3, ExponentFunction -> (Null &)] &;



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