fixed a bug with capitalizing the word before ref

There are 2 bugs actually: 
1. The word before the \ref can be the beginning of a paragraph/sentence so it might not have a space or tilda until the previous sentence. So we should take the last word in such cases.
2. The offsets for the error are in the latex_text representation, but by default the print falls back to plain text when the text is not specified on print_issue