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 am using a LaTeX template from my university to typeset my thesis. I am making references to R and I have defined a new command with:

\newcommand{\R}{R}

in order to get the roman "R". The formatting of the thesis means that chapter titles are written in a sans serif font. When I type a chapter title e.g. "\R{} source code" it does not appear in serif, rather in the same sans serif font at the rest of the title.

Is there a way to force the "base" font to be used, regardless of which font is in use at that time?

Sorry for no minimal working example - I'm just not sure which part of the preamble causes the chapter titles to be sans serif!

share|improve this question
1  
Notice that "script font" usually refers to a calligraphic one. I've edited the question title to reflect the text. Welcome to TeX.SX! –  egreg Sep 18 '12 at 19:37
add comment

migrated from stackoverflow.com Sep 18 '12 at 19:20

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

In addition to suggestions from @bdh_dtu and @egreg you might want to also add in the xspace package:

\usepackage{xspace}
% combine suggestions from @bdh_dtu and @egreg with xspace
\newcommand{\R}{\textup{\textrm{R}}\xspace}

\xspace tries to be clever about inserting a space after the macro if there would normally be one but not if there shouldn't be one, such as when writing \R. (i.e. ending the line with \R followed by a full stop.

share|improve this answer
add comment

Found it! Courtesy of Stefaan Lippens. Use:

\textnormal{} % to use the LaTeX font of the main body text (usually serif)
\textrm{}     % to force Roman font (serif)
\textsf{}     % to force sans serif font

Stefaan explains why in detail, and also gives a working example.

To complete my answer, the new command should be changed to:

\newcommand{\R}{\textrm{R}}
share|improve this answer
3  
If you also need to ensure upright shape, then \newcommand{\R}{\textup{\textrm{R}}} –  egreg Sep 18 '12 at 19:34
add comment

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.