Tag Info

Hot answers tagged

8

You can also use MapAt with Invisible or Style[#,White]&: f1 = MatrixForm[MapAt[Invisible, #, Position[#, Except[#2], {2}, Heads->False]]] &; (* or f1 = MatrixForm[MapAt[Style[#,White]&, #, Position[#, Except[#2], {2}, Heads->False]]] &; *) Example: m = RandomInteger[5, {5, 5}]; Row[Prepend[f1[m, #] & /@ {1, 2, 1 | 2}, ...


7

Version 10 introduced some undocumented functionality that makes it easier to explore the style hierarchy. As usual, "undocumented" === "buyer beware". We start by evaluating: StyleManager`OpenStyleManager This does nothing other than trigger the auto-loading of certain symbols. We'll come back to a more interesting use of this symbol later. Now, we ...


5

Here's a variation you might find useful: fn[a_?ArrayQ, x_] := Replace[a, p : Except[x] :> Style[p, White], {ArrayDepth@a}] // MatrixForm Now: fn[IdentityMatrix[3], 1] But because the non-selected elements are only styled white they appear when selected:


5

f[x_List, n_] := (x /. y_ /; y != n -> " ") // MatrixForm f[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, 7] If you need to display only elements in list n, then use: g[x_List, n_List] := x /. y_ /; (MemberQ[Complement[Flatten[x], n], y]) -> " " // MatrixForm g[{{1,2,3},{4,5,6},{7,8,9}}, {3,7}] I'm sure there's a more elegant way to do this last ...


5

If you want to do it all programmatically you could import the notebook containing the cells with graphics and change the cell style for cells containing graphics: changeStyle[file_String, newStyle_String] := Module[{nb = NotebookOpen[file], nb1}, nb1 = NotebookGet[nb]; NotebookClose[nb]; nb = nb1 /. (p1 : Cell[BoxData[GraphicsBox[_, ___]], ...


4

As Nasser already pointed out that exponential expressions are converted into powers. You can find the corresponding documentation in the Possible Issues section of Exp When you know this, than you can circumvent the issue by holding your expression and replacing all exponential powers to Exp[..] again. Therefore, a simple solution is FormatExp[expr_] := ...


4

New answer Here is a modularized method. The first function is from Trying to write out the prime factorization of a number with CenterDot and Superscript, slightly modified. Format[primeFactorForm[n_Integer]] := Times @@ Superscript @@@ FactorInteger[n] /. _[x_] :> x block[n_Integer] := Join @@@ Array[{#, primeFactorForm@#} &[# + 16*#2] ...


3

For Graphics output specifically there is a nice approach using $DisplayFunction: (* create a new output style -- overwrites existing custom style sheet *) SetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], Cell[StyleData["altOutput"], TextAlignment -> Center]}, ...


3

An alternative is to use $Post to post-process output automatically as it is generated. For instance, the following outputs anything with the head Graphics in a style "centeredOutput", which could be defined in whatever manner one wants. centerGraphics[g_Graphics | g_Graphics3D] := CellPrint@ExpressionCell[g, "centeredOutput"]; centerGraphics[x_] := x; ...


3

Yet another realization of the straightforward idea t = Table[i/j + 4*Boole[j > i] // N, {i, 3}, {j, 4}]; h = {{"Row1", "Row2", "Row3"}, {"Col1", "Col2", "Col3", "Col4"}}; Style[TableForm[# /. x : Max@# :> Style[x, Bold] & /@ t, TableHeadings -> h], FontFamily -> "Times"] I change FontFamily for better visibility


2

TableForm[ (m = Max[#]; (# /. m :> Style[m, Red] ) ) & /@ Table[i/j + 4*Boole[j > i] // N, {i, 3}, {j, 4}] , TableHeadings -> {{"Row1", "Row2", "Row3"}, {"Col1", "Col2", "Col3", "Col4"}}] Red is easier to see but Bold works as well..


2

Maybe the simplest method is CForm with small string postprocessing moodleForm[expr_] := StringReplace[#, {"power" -> "pow", "md(" ~~ Shortest@x__ ~~ ")" :> "{" ~~ x ~~ "}"}] &@ ToLowerCase@ToString[#, CForm] &@Simplify[expr, Assumptions -> _md ∈ Reals] StandardDeviation[{md[a], md[b], md[c]}] // moodleForm (*sqrt(pow({a},2) + ...


2

Select the cell containing your output, then choose TraditionaForm from the Convert To submenu of the Cell menu. The cell will then show Update Perhaps this is what you are looking for: (f^(1,0,0))[x, y, z]/(h^(1,0,0))[x, y, z] /. h_[x, y, z] -> h


1

A look at the FullForm motivates e.g. this: der = Derivative[1, 0, 0][f][x, y, z]/Derivative[1, 0, 0][h][x, y, z]; der /. Derivative[a___][b___][c___] :> Derivative[a][b]


1

Using Position with MapAt: ClearAll[sF]; sF = With[{pos = Thread[{Range@Length@#, Position[#, Max@#][[1, 1]] & /@ #}]}, MapAt[Style[#, Bold, Red] &, #, pos]] &; t = Table[i/j + 4*Boole[j > i] // N, {i, 3}, {j, 4}]; h = {{"Row1", "Row2", "Row3"}, {"Col1", "Col2", "Col3", "Col4"}}; TableForm[sF@t, TableHeadings -> h] ... with ...


1

If you are trying to place each grid into a separate cell, change the last line to this: Scan[Print, Array[grid @ block @ # &, 4]] or this: Print ~Scan~ Array[grid@block@# &, 4] or this: Array[grid@block@# &, 4] // Scan[Print, #]& ... as suits your taste. Mathematica version 10 allows this nice-looking alternative form: Array[grid ...


1

It is possible to change the style used for output with this Front End option: "GeneratedCellStyles" -> {"Output" -> (* style *)} One can change this style as part of the output formatting routine using $PrePrint, like this: defaultOut[] := SetOptions[EvaluationNotebook[], "GeneratedCellStyles" -> {"Output" -> "Output"}] altOut[] := ...



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