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 ReplacePart
:
ClearAll[sF2];
sF2 = With[{m=#, pos = Thread[{Range@Length@#, Position[#, Max@#][[1, 1]] & /@ #}]},
ReplacePart[m, (# -> Style[m[[## & @@ #]], Bold, Red]) & /@ pos]] &;
TableForm[sF2@t, TableHeadings -> h]
(* same picture *)
... with Part
assignment:
ClearAll[sF3];
sF3 = Module[{r=#, p = Position[#, Max@#][[1]]},
(r[[#]] = Style[r[[#]], Bold, Red]) & /@ p; r] & /@ # &;
TableForm[sF3@t, TableHeadings -> h]
(* same picture *)