Producing Script r In LaTeX Expressions

When we have so many letters already, why would one need this fancy little Script r? While typesetting mathematical expressions that govern our (beautiful & elegant) physical universe, often one runs out of symbols and as such, it becomes necessary to use the same letter/character in different styles to convey the intended meaning. Electrodynamics and Gravitation are just a couple such fields that often use – fortunately or unfortunately – a variation of alphabet r, called the script r. I did try to generate this elusive script r in LaTeX for quite a few years and failed miserably every time. However a few days ago, Dr. Cantrell was looking for a way to accomplish the same and as such revived my almost forgotten interest in script r.

Script r – MS Windows

A little bit of Google-ing led me to a discussion forum. The method described there [included below for completeness sake] works just fine in Microsoft Windows running [a full installation of] MiKTeX and WinEdt.

1
2
3
4
5
6
\usepackage{calligra}
\DeclareMathAlphabet{\mathcalligra}{T1}{calligra}{m}{n}
\DeclareFontShape{T1}{calligra}{m}{n}{<->s*[2.2]callig15}{}
 
% A new, shorthand command/macro to generate 'script r'
\newcommand{\scriptr}[1]{\ensuremath{\mathcalligra{#1}}}

Script r – Mac OS

While the code that generates is the same as in Microsoft Windows [MiKTeX/WinEdt], there are few things that ones need to do to get this elusive thing. First off, download the following three files and save them on Desktop.

calligra.sty | calligra.mf | callig15.mf


Open a Terminal and type the following:

mkdir -p ~/Library/texmf/tex/latex
mkdir -p ~/Library/texmf/fonts/mf
 
cp ~/Desktop/calligra.sty ~/Library/texmf/tex/latex/
cp ~/Desktop/calligra.mf ~/Library/texmf/fonts/mf/
cp ~/Desktop/callig15.mf ~/Library/texmf/fonts/mf/
 
sudo texhash

Once these steps were followed, I was able to successfully compile LaTeX document and generate script r using TeXShop as well as texmaker.

Script r – Linux

While the code that generates is the same as in Microsoft Windows [MiKTeX/WinEdt], just like in Mac OS, there are few things that ones need to do to get this elusive thing. First off, download the following three files and save them on Desktop [it should, however, be noted that I did a full/maximal installation of Linux (Red Hat Enterprise/CentOS) and as such, LaTeX (with all necessary dependencies) was installed by default].

calligra.sty | calligra.mf | callig15.mf


Open a Terminal and type the following as root:

mkdir -p /usr/local/share/texmf/tex/calligra/
mkdir -p /usr/local/share/texmf/fonts/source/public/calligra/
 
cp ~/Desktop/calligra.sty /usr/local/share/texmf/tex/calligra/
cp ~/Desktop/calligra.mf /usr/local/share/texmf/fonts/source/public/calligra/
cp ~/Desktop/callig15.mf /usr/local/share/texmf/fonts/source/public/calligra/
 
texhash

Add the following line to individual user’s .bashrc and source it before proceeding ahead.

export TEXINPUTS="${TEXINPUTS}:/usr/local/share/texmf/tex/calligra/"

Once these steps were followed, I was able to successfully compile LaTeX document and generate script r using command line.

Sample Input File & Screenshot

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
\documentclass[letterpaper]{article}
 
% Packages Required
\usepackage[dvips]{graphicx}
\usepackage{amsmath,amssymb}
\usepackage{color,setspace}
\usepackage{natbib}
 
% For generating 'script r'
\usepackage{calligra}
\DeclareMathAlphabet{\mathcalligra}{T1}{calligra}{m}{n}
\DeclareFontShape{T1}{calligra}{m}{n}{<->s*[2.2]callig15}{}
 
% A new, shorthand command/macro to generate 'script r'
\newcommand{\scriptr}[1]{\ensuremath{\mathcalligra{#1}}}
 
% Page Format Details
\setlength{\oddsidemargin}{0.00in}      % Margin on the Odd Numbered Side
\setlength{\evensidemargin}{0.00in}     % Margin on the Even Numbered Side
\setlength{\topmargin}{0.00in}          % Margin from the top
\setlength{\textwidth}{6.50in}          % Width of the text in a page
\setlength{\textheight}{9.00in}         % Height of the text in a page
\setlength{\parindent}{0.00in}          % New paragraph indentation
\setlength{\parskip}{0.25in}            % Spacing between two paragraphs
 
\pagestyle{plain}                       % Page Style
 
\begin{document}
 
\begin{center}
\large Script $r$ ($\scriptr{r}$) in \LaTeX\
\end{center}
 
The magnitude of the electrostatic force, $F$, on a charge
$q_{1}$ due to the presence of another charge $q_{2}$ is given by
 
\begin{equation*}
F \;=\; \frac{1}{4\pi\epsilon_{\circ}}\:
        \frac{q_{1}\:q_{2}}{\left| \mathbf{r} \:-\: 
        \mathbf{\scriptr{r}}\right|^{2}}
\label{EQN00}
\end{equation*}
 
where $\left| \mathbf{r} \:-\: \mathbf{\scriptr{r}}\right|$ is
the distance between $q_{1}$ and $q_{2}$. A positive force implies
a repulsive interaction, while a negative force implies an
attractive interaction.
 
\end{document}


Script r

2 Replies to “Producing Script r In LaTeX Expressions”

  1. Hey,

    This is a great start, in that you can at least get a script r. But, theres no distiction between the bold one and the normal one, which makes it hard to use in physics text, where it usually denotes a vector.

    One way to get acces to both a normal script r and a bold one is through the safly-not-open.source mtpro2 fonts.

    Anyone knows how to do it for free?

Leave a Reply to Mikl Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.