I work in a specialist unit for secondary kids with ASD.
Personal hygiene is a big focus. Many of the kids just don't realise a) they smell, b) what they need to do about it, c) that it annoys other people and d) it may cause others to react badly to them. These are highly verbal children with good learning abilities in the context of ASD. Many of those who struggles most with hygiene could not be spotted by anyone on the street as having a disability.
There are many reasons why an individual with ASD might struggle with personal hygiene.
A person with an ASD may not have picked up the correct steps to wash themselves properly and/or may struggle to execute these. Part of the teaching programme for some of our students involves discussing the things you need to do when you wash - rinsing etc. This possibly has to do with observational learning: typically, kids pick up the steps of how to wash from observing how it is done. A child on the spectrum may not have perceived these steps in the same way as a child without an ASD and may, for example have been fixated on the way the water rippled or the smells and sounds of the bathroom vs what is happening and in what order.
Many individuals with ASD struggle with organising themselves to do routine things as they may be preoccupied with other things, including their own special interests. The person in the library might very well be so involved in thinking about his research in such a rigid way that they don't even realise they haven't washed.
Many individuals with ASD struggle with sensory aspects of washing - they don't like the feeling of the soap, or the smell of deodorant, or how the water feels on their body. I have personally worked with many students with ASD who are phobic of water because they found the experience of bathing overwhelming as young children.
Some people who have an ASD find things like labels on clothes painful. If you compare the pressure of a label on clothes to a power shower, you can quickly realise how washing etc might actually be physically painful to a person who is on the spectrum. At the other end of the scale, some people have hyposensitivity to smells: so may not actually perceive that they smell any differently to other people.
Not all individuals with ASD have a realistic sense of how they look/smell/appear to others. A student we work with has only recently realised that his skin colour is brown: he self-characterised himself as "white" when there was talk about census data as that is "skin colour". He had never realised from looking at himself in the mirror that his colour was not white (despite being in a school where 90% of students are black). Again, this is a student that no one would be able to tell was any different to others by looking at him.
This is just a snapshot of how and why individuals who are on the spectrum can find it hard to conform to one social norm and it is by no means exhaustive.