1

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.

Werner
  • 603,163
Dov
  • 1,481

2 Answers2

2

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}
Werner
  • 603,163
0

You can use ~ after the ohm statement in order to force the space. It is used to ensure whatever is attached by ~ does not break to the next line so it is not always appropriate. That being said it is the quickest fix I have found.

Resistor value of 50~\ohm~used in...