2

I’m making a summary of definitions for Linear Algebra. I need to underline all vectors. This takes me a lot of time because \underline{u} is a long command to type. Is there a way to set an alias for \underline{} (for example, \und{})?

I would also like existing usages of \underline to keep working.

  • 2
    Do you just want \let\und\underline? – Ian Thompson May 18 '15 at 12:24
  • I would like to have a fast key to underline words... – BioShock May 18 '15 at 12:24
  • Using \let makes a copy of a command; I think this is what you need. – Ian Thompson May 18 '15 at 12:25
  • OK, I've given a slightly more detailed answer below. It may be that this (or something very similar) has been asked before on this site, but if there is a duplicate, I have been unable to find it. – Ian Thompson May 18 '15 at 12:32
7

You can use \newcommand to create abbreviated versions of standard macros. In your case, you could put something like

\newcommand\und[1]{\underline{#1}}

in the preamble. However, this can get awkward if you want to abbreviate more complex commands with multiple arguments and/or optional arguments. A neater way is to copy the macro definition using \let

\let\und\underline
  • 3
    Or even \newcommand\und{\underline}. – Aditya May 18 '15 at 13:33
  • @Aditya --- Indeed. I always forget that trick. – Ian Thompson May 18 '15 at 14:03
4

While Ian's answer works, it might be a better idea to redefine the \vec command and use \vec{u}, instead of defining a shorter underline command:

\renewcommand{\vec}{\underline}

Then you have a clear distinction between vectors and things that are underlined for some other reason.

If you later change your mind and want vectors to be bold, for example (or you want to use the same equations in another document with that formatting), then you can just change the definition of \vec, instead of changing every \und in the document or change that definition to have \und mean bold (which would be strange, and cause error if you used \und for other things as well).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.