# How to typeset the name of a category?

I'm LaTeXing some category theory, and typeset the names of my categories in boldface (Set, Rel, ...). Since I might want to change that, I put

\newcommand{\catname}[1]{\textbf{#1}}
\newcommand{\Set}{\catname{Set}}
\newcommand{\Rel}{\catname{Rel}}
...


in my document header. But textbf very kindly respects the italics elsewhere in the document, so that if I try to typeset a category inside a definition (say) I get Set. I don't want this -- I'd like the categories to be upright.

I tried

\newcommand{\catname}[1]{{\bf #1}}
\newcommand{\catname}[1]{\ensuremath{\boldsymbol{\operatorname{#1}}}}


but these both ruin the spacing after the category name. Help! =)

-
Any suggestion for the change in requirements since my answer was unaccepted? –  Werner Aug 7 '12 at 20:25
@Werner I realised that your answer, though correct, doesn't actually solve the problem, because the problem isn't where I thought it was. (LaTeX doesn't get the spacing right around \ensuremaths, I think. I can try to make an MWE if you'd like.) I'm putting together an answer/update now, but it's hard to extract the bug from the several-thousand lines of dissertation =p –  katrielalex Aug 7 '12 at 21:46
You can reformat the spacing using elements like \mathbin, \mathrel, \mathord, etc. However, the problem spacing has to be visualized (via code/picture) in order to find the best solution. –  Werner Aug 7 '12 at 21:50
@Werner I'll ask a new question, so you have the accept again =) –  katrielalex Aug 10 '12 at 4:47

You can wrap it in a group and add \normalfont to it; this will localize the font change initiated by \normalfont. This way it will revert back to the default before setting it in bold:

\documentclass{article}
\newcommand{\catname}[1]{{\normalfont\textbf{#1}}}
\newcommand{\Set}{\catname{Set}}
\newcommand{\Rel}{\catname{Rel}}
\begin{document}
Here is \Set. \par
\itshape Here is \Set. \par
\sffamily Here is \Set.
\end{document}


If you wish to maintain the current font family as well yet only print it upright, use

\newcommand{\catname}[1]{\upshape{\textbf{#1}}}


Note the difference in the last entry when using the above definition:

-
Why not \textnormal{\textbf{#1}}? However I definitely prefer \mathbf since this is math. –  egreg Aug 3 '12 at 20:17

Replacing \textbf by \mathbf seems to work fine.

\documentclass{article}

\newcommand{\catname}[1]{\mathbf{#1}}

\begin{document}

\emph{\dots in the category $\catname{Set}$.}

\end{document}

-
True -- but only in math mode! =) –  katrielalex Aug 3 '12 at 18:42
@katrielalex The name of a category is math. –  egreg Aug 3 '12 at 18:45
This approach makes it simpler to keep the coherence of the fonts in the file, since changing mathbf to a different font will also change the font of your categories, and all other symbols you decided should share the same bold font without altering the bold font outside the math environment. –  Gustavo Aug 3 '12 at 18:50
@GustavoJasso Oh, I agree -- I definitely don't think changing mathbf would be a good idea. I'm not sure why I think of category names as non-math... I may have been doing this too long! –  katrielalex Aug 3 '12 at 20:31
@katrielalex I don't understand your comment, do you mean textbf? –  Gustavo Aug 3 '12 at 20:44