[Tex/LaTex] Why is there no space after omega (and what can I do after it)

macrosspacing

I put omegas in my text as needed using a command:

\newcommand{\ohm}{$\Omega$ }

Then I needed other symbols so I included package gensymb. But when I do, \ohm is already defined. So I tried using the one defined in the library. It does not add a space afterward, not sure why. My \kohm and \Mohm work fine. I'm not sure whether I should be overriding the \ohm command. What is the best approach to solve this problem?

MWE:

\documentclass[12pt]{book}
\usepackage{gensymb}
\newcommand{\fahren}{\degree F}
%\newcommand{\cels}{\degree C}
%\newcommand{\ohm}{$\Omega$ }
\newcommand{\kohm}{k$\Omega$ }
\newcommand{\Mohm}{M$\Omega$ }

\begin{document}
test \ohm
test \kohm
test \Mohm
I measure temperature in \fahren
\end{document}

I do not want to have to add braces or a backslash after the command: \ohm{} or \ohm\

The \kohm command works as I want it to, inserting a space afterward because it is an equation. I suppose I can define a \ohm command that is exactly the same as \kohm but then I would have to replace every one of the \ohm commands in multiple documents.

Best Answer

It's really your choice. If you want to use \ohm the way you defined it, the load the gensymb package and redefine \ohm:

\usepackage{gensymb}
\AtBeginDocument{\renewcommand{\ohm}{$\Omega$ }}

The redefinition is delayed until \AtBeginDocument, as gensymb looks for the presence of textcomp in order to define an appropriate \ohm.

Forcing a space after the command wouldn't always work, as you'll see when you use something like Check out this \ohm. For general attempts at adding spaces of commands, see Space after LaTeX commands.

enter image description here

\documentclass{article}

\usepackage{gensymb}

\AtBeginDocument{\renewcommand{\ohm}{$\Omega$ }}

\newcommand{\fahren}{\degree F}
\newcommand{\kohm}{k$\Omega$ }
\newcommand{\Mohm}{M$\Omega$ }

\begin{document}

test \ohm
test \kohm
test \Mohm
I measure temperature in \fahren. test \ohm.

\end{document}
Related Question