Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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! =)

share|improve this question
    
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
add comment

2 Answers

up vote 2 down vote accepted

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:

enter image description here

\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:

enter image description here

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

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}
share|improve this answer
    
True -- but only in math mode! =) –  katrielalex Aug 3 '12 at 18:42
3  
@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
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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