# Underline numbers in matrix

``````julia> Matrix(reshape(1:100,10,10))
10Γ10 Matrix{Int64}:
1  11  21  31  41  51  61  71  81   91
2  12  22  32  42  52  62  72  82   92
3  13  23  33  43  53  63  73  83   93
4  14  24  34  44  54  64  74  84   94
5  15  25  35  45  55  65  75  85   95
6  16  26  36  46  56  66  76  86   96
7  17  27  37  47  57  67  77  87   97
8  18  28  38  48  58  68  78  88   98
9  19  29  39  49  59  69  79  89   99
10  20  30  40  50  60  70  80  90  100
``````

How to underline the perfect squares 1,4,9 etc?

PrettyTables.jl may help you do thatβ¦ but I donβt think it allows underlining.

This underlines the squares, but the alignment is off:

``````julia> issquare(n) = isqrt(n)^2 == n

julia> import Markdown

julia> [Markdown.parse(issquare(i) ? "_\$(i)_" : "\$i")  for i in reshape(1:100,10,10)]
``````

This prints the squares in bold (using Unicode bold digits):

``````julia> boldnum(n::Integer) = map(c -> c + ('π'-'0'), string(n))

julia> [Text(issquare(i) ? boldnum(i) : "\$i")  for i in reshape(1:100,10,10)]
10Γ10 Matrix{Text{String}}:
π   11  21  31  41  51  61  71  ππ  91
2   12  22  32  42  52  62  72  82  92
3   13  23  33  43  53  63  73  83  93
π   14  24  34  44  54  ππ  74  84  94
5   15  ππ  35  45  55  65  75  85  95
6   ππ  26  ππ  46  56  66  76  86  96
7   17  27  37  47  57  67  77  87  97
8   18  28  38  48  58  68  78  88  98
π   19  29  39  ππ  59  69  79  89  99
10  20  30  40  50  60  70  80  90  πππ
``````
2 Likes