# Underline numbers in matrix

**URL:** <https://discourse.julialang.org/t/underline-numbers-in-matrix/78112>\
**Category:** General Usage\
**Created:** [March 18, 2022, 9:42pm UTC](https://discourse.julialang.org/t/underline-numbers-in-matrix/78112 "2022-03-18T21:42:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [March 18, 2022, 9:42pm UTC](https://discourse.julialang.org/t/underline-numbers-in-matrix/78112/1 "2022-03-18T21:42:15Z")

</div>

```julia
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?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [March 18, 2022, 9:43pm UTC](https://discourse.julialang.org/t/underline-numbers-in-matrix/78112/2 "2022-03-18T21:43:40Z")

</div>

PrettyTables.jl may help you do that… but I don’t think it allows underlining.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [March 18, 2022, 10:55pm UTC](https://discourse.julialang.org/t/underline-numbers-in-matrix/78112/3 "2022-03-18T22:55:22Z")

</div>

This underlines the squares, but the alignment is off:

```julia
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
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 𝟏𝟎𝟎

```
