I'm trying to vertically offset some underscores in a filename representation: some_file_name.ext
so that the underscore is moved above the baseline. Here is what I tried def'ing:
\def\raiseunderscore#1-#2{\dimexpr\height#1#2\relax}
but I'm getting error: ! You can't use `\dimexpr' in restricted horizontal mode.
So in my notoriously fragmented competence on TeX primitives, I tried:
\def\raiseunderscore#1-#2{\leavevmode\dimexpr\height#1#2\relax}
to no avail.
How can I vertically offset the underscore character when used in normal text as _? Also, is there a way I can have this occur in all instances (globally) instead of making a macro for it?
Update: Here is what I am trying to achieve (I've changed the macro name for brevity) :
Here is a short MVE of what I've tried so far:
\documentclass{article}
\def\offsetchr#1#2{\dimexpr\height#1#2\relax}
\begin{document}
This sentence has a raised\quad\offsetchr{15pt}{\_} \quad character in the middle.
This sentence also has a raised\quad\offsetchr{2.5em}{\_} \quad character in the middle.
This sentence has a lowered\quad\offsetchr{-2.5em}{\_} \quad character in the middle.
\end{document}
\dimexpr
just computes an (dimension) expression, it doesn't move things around. Can you please show a compilable example of what you're trying?