This version currently does not allow asking for the man page of things like “5 vpnd”
Subtly adjusting the quoting resolves the problem:
CMD="$KMVAR_Shell_command";
man -t $CMD | pstopdf -l -i -o "$HOME/Desktop/$CMD.pdf"
open -a Preview "$HOME/Desktop/$CMD.pdf"
By removing the quoting around the $CMD in the man, you can have the two parameters, and by quoting the $CMD in the path and the open, the file name can have a space in it.
Speaking of which, technically $HOME can have a space in it too, so it should always be quoted - this lead to a significant data loss bug in an iTunes update for folks with this issue.