There are a number of times when I'm writing LaTeX documents when I need to write a character with an accent or diacritic in it. For instance, the "ô" needed to write "L'Hôpital" (in reference to his titular rule) came up quite frequently in writing notes for my calculus class.
Of course, this extends to other accented characters and the like, often for names (e.g. Paul Erdős, René Descartes, Otto Hölder). Some can be seen here.
Writing these out in LaTeX has become a bit of a chore for me, mainly because I struggle to remember the actual codes to use them or often mix them up. I'm writing on a standard English keyboard as well, so "just type the character into the document" results in me having to copy-and-paste it from elsewhere. So either way I have to look something up - the list of codes, or something with the character in it.
It would be easier for me if I could have some sort of piece of code that automatically detects a relevant string, and replaces it with one with the corrected accent. So for instance, something that would see that I'd typed
L'Hopital, and replace it with
L'Hôpital instead, in the resulting PDF.
Of course, it would be trivial to define a macro that does it, something like
but using this feels clunky and unnatural, especially for something that is almost surely going to be rendered outside of math mode.
I feel like something like this may be possible based on some searching I've done in the past. For instance, this post changes it so that
:= generates what you would expect, but with better vertical alignment of the colon with respect to the equal sign. Granted, I have a hard time parsing what exactly the snippet of code is doing... But regardless, that code works exactly like I'd envision: zero extra effort on my part aside from putting in the code.
So in short, what I'd ideally like is something which can automatically replace a text string I type in the document, with a particular text string I want to replace it with. Hence whenever I type
L'Hopital I get
Erdos I get
Erdős, and so on and so forth - in general, I type
stringA and obtain
stringB in the output.
Thanks for any help you can give!