I found this thread, because I had the same issue and I tested a huge bunch of teletype fonts and got stuck with cfr-lm
. But loading the whole cfr-lm
package would be overkill so I just did:
\renewcommand{\ttdefault}{clmjv}
Which is equivalent to
\usepackage[tt={oldstyle=true,variable=true}]{cfr-lm}
Showcase
In the following example of a bibliography with biblatex
the DOI is typeset with cfr-lm
.
If you want to typeset source code it might be better to use the tabular version of cfr-lm
as you usually want to align stuff in your code. Personally I think that lining figures also look better in code. Therefore I'd use
\renewcommand{\ttdefault}{clmt}
which is equivalent to
\usepackage[tt={oldstyle=false,variable=false}]{cfr-lm}
Showcase
This piece of code is taken from another answer I once gave.
% arara: pdflatex: { shell: yes }
\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage[T1]{fontenc}% cfr-lm is T1 only
\usepackage{minted,MinionPro,caption}
%\renewcommand{\ttdefault}{clmjv}% oldstyle, proportional
\renewcommand{\ttdefault}{clmt}% lining, tabular
\newcommand\code{\texttt}
\newcommand\param{\textit}
\DeclareCaptionFont{bfmath}{\boldmath\bfseries}
\DeclareCaptionFormat{ruled}{\hrulefill\par#1#2#3}
\captionsetup{format=ruled,font=bfmath}
\begin{document}
\begin{figure}
\centering
\begin{minted}{c}
const uint8_t *data = /* buffer head */;
const uint8_t *data_end = /* buffer tail */;
int size = bytestream_get_be16(&data);
if (data + size >= data_end || data + size < data)
return -1;
data += size;
...
int len = ff_amf_tag_size(data, data_end);
if (len < 0 || data + len >= data_end
|| data + len < data)
return -1;
data += len;
/* continue to read data */
\end{minted}
\caption{Unstable bounds checks in the form $\code{data} + x < \code{data}$ from FFmpeg/Libav, which gcc optimizes into $x < 0$.}
\end{figure}
\end{document}
Using unicode-math
:
\usepackage{amsmath} % always load before mathspec or unicode-math
\usepackage[math-style=ISO]{unicode-math} % try sans-style=upright
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
\setmainfont[Numbers={OldStyle,Proportional},SmallCapsFeatures={LetterSpace=6},%
BoldFont={Myriad Pro Bold},BoldFeatures={LetterSpace=3}]{Minion Pro}
\setsansfont[Numbers={OldStyle,Proportional},LetterSpace=3]{Myriad Pro}
\setmonofont{Crystal}
\setmathfont{xits-math.otf}
\setmathfont[range=\mathup/{num,latin,Latin,greek,Greek}]{Minion Pro}
\setmathfont[range=\mathsf/{num,latin,Latin,greek,Greek}]{Myriad Pro}
\setmathfont[range=\mathbfsf/{num,latin,Latin,greek,Greek}]{Myriad Pro Bold}
\setmathfont[range=\mathit/{num,latin,Latin,greek,Greek}]%
{Minion Pro Italic}
\setmathfont[range=\mathsfit/{num,latin,Latin,greek,Greek}]%
{Myriad Pro Italic}
\setmathfont[range=\mathbfsfit/{num,latin,Latin,greek,Greek}]%
{Myriad Pro Bold Italic}
\setmathfont[range=\mathtt->\mathup]{Crystal}
\let\mathbf\mathbfsf
\let\mathbfit\mathbfsfit
\AtBeginDocument{\let\phi\varphi}
(N.B. unicode-math
loads fontspec
, xltxtra
, and xunicode
)
mathbb
, mathscr
, &c. all have sensible defaults with this. If you want, say, serifed mathbb
, you could add \setmathfont[range=\mathbb/{Latin}->\mathup,Scale=MatchUppercase]{Hoefler Text Engraved}
. The /{Latin}
part applies it only to uppercase latin letters.
- Use
BoldFont
and BoldFeatures
with fontspec
. For unicode-math
, I just used \let
commands, although I know there's probably a more elegant way to do this.
- Removing
MnSymbol
frees up a lot of math alphabets, and unicode-math
increases the limit.
- Apparently Ubuntu Mono is bugged; I couldn't use it, so I tested with Crystal. And it works.
EDIT: To use Minion for even more symbols, you could replace the \mathup
line with:
\setmathfont[range={\mathup/{num,latin,Latin,greek,Greek},\question,\exclam,\mathdollar,%
\percent,\ampersand,\lparen,\rparen,\plus,\comma,\period,\mathslash,\mathcolon,%
\semicolon,\less,\equal,\greater,\backslash,\rbrack,\lbrack,\atsign,\vert,\lbrace,%
\rbrace,\times,\div}]{Minion Pro}
Best Answer
The quickest way to get a bold teletype font in math mode is to use the
\text
commands fromamsmath
.To get the ds blackboard symbols, I would recommend
This enables
\mathbb
for double-struck, and\mathbbb
for bold double-struck.There is also a Minion Math font family for use with
unicode-math
, although it will cost you money.