Beautifully print the matrix in math

I have a list of lists (matrix) in math. I want to print it beautifully, with max in each line in bold. How to do it?

Or maybe even further, with a circle outside such a maximum, is this possible?

+8
wolfram-mathematica
source share
2 answers

You can use MatrixForm for beautiful matrix output:

 data = RandomInteger[100, {5, 5}]; data // MatrixForm 

gives

MatrixForm image

You can draw a circle around the maximum in each line as follows:

 Map[# /. m : Max[#] :> Framed[m, RoundingRadius -> 1000] &, data] // MatrixForm 

getting

matrix with circles

RoundingRadius -> 1000 uses a ridiculously large parameter to get circles. You may need to adjust the constant depending on the scale of your display.

You can change Framed[m...] to Style[m, Bold] if you like bold.

+19
source share

Grid [] gives fine grain control on an external display. For example:

 g[a_] := Grid[a, Background -> {None, {{LightBlue, LightRed}}}, Dividers -> {False, All}, ItemStyle -> {Automatic, Automatic, MapIndexed[Flatten@{#2, Ordering[#1, -1]} -> {Bold, Red} &, a]}] g[RandomInteger[100, {10, 7}]] 

enter image description here

NB> It will select only one element per line

Edit

To highlight each max element, you can do, for example:

 g[a_] := Grid[a, Background -> {None, {{LightBlue, LightRed}}}, Dividers -> {False, All}, ItemStyle -> {Automatic, Automatic, Flatten[Tuples[{First@#, Last@#}] & /@ MapIndexed[{#2, Position[#1, Max[#1]]} &, a], 1] /. {q_, {r_}} -> ({q, r} -> {Red, Bold})}] 

enter image description here

+8
source share

All Articles