Dynamically reformatting man pages on terminal dimension changes
The basic problem is that the formatting is done by one program and the paging is done by another. Even if the formatter were to get a signal that the window size has changed and reformat the text for the new window size, all it can do is feed new text down the pipeline to the pager. There's no way for the pager to know with certainty what position in the new stream corresponds to the position in the old stream it was currently displaying.
What you need is for the pager to be able to do the reformatting. As @Robin Green said, that's HTML.
If you want to use HTML but still work in a terminal, you can tell man(1)
to output in HTML and call a text-mode browser to display it.
man -Hlynx man
That will display the man(1)
manpage in the lynx text-mode browser. Lynx does not directly respond to window size changes, but you can press ctrl-R and lynx will re-render the page for the new window size.
There are two other text-mode browsers that I know of: links and elinks. You could experiment with those and lynx and determine which give you the best experience for browsing man pages. You may want to use a custom configuration just for man pages and invoke a script that invokes the browser with that specific configuration.
You can put the man options you like into the MANOPT
environment variable.
$ export MANOPT=-Hlynx
$ export MANOPT=-Hmanlynx # provide your own wrapper to execute
# lynx with a different configuration.
You will need to install the groff
package for man
to be able to generate HTML.
Convert the man pages to html on the fly using a suitable script such as manserver, viewing them in a web browser (which can of course be a text-based web browser like lynx).
This is presumably why no-one has solved this problem - because the problem became irrelevant with the development of man->html scripts.