Special LaTeX symbols



Hunting particular characters/dingbats/emoji/etc for latex?

90% of questions to this theme can be answered by the Latex Math Symbols Cheat sheet, or the full-length Not so short introduction to LaTeX.

There is an offline package, The Comprehensive LaTeX Symbol List, Notionally one can invoke this using

texdoc symbols-a4

However AFAICT it has very heavy dependencies and requires a comprehensive LaTeX install. This is not enough:

tlmgr install texdoc comprehensive

Sometimes we need to use special fonts and character encodings to get the desired effect. Life is much easier in Unicode for new projects (but beware wacky problems with legacy projects.) One of the great things about unicode maths is that some of the special symbols problems go away, because if you can find a special symbol in the unicode symbol list, or whatever they call it, you can use it in your document. The process to do that in class LaTeX is much more onerous — It would probably be better to import a single glyph via pifont or yagusylo.

Emoji

There are several ways to insert emoji into LaTeX.

Elegant, LuaLaTeX and XeTeX have native monochrome emoji via standard unicode fonts. The DejaVu one is fine.

\documentclass{article}
\usepackage{fontspec}

% these lines must come after fontspec
\newfontfamily\DejaSans{DejaVu Sans}
\newcommand\todo{{\color{red}\DejaSans 🚧}}

\begin{document}
  \todo mention {\DejaSans 😁😂😃😇😉😈😋😍😱}
\end{document}

Want color? The dirty-yet-shiny hack to include color emoji as images works This needs a Mac computer lying around to raid for the images, as a one-off. One could probably also try the joypixels emoji, although their license prohibits free commercial use, so be careful with where they are deployed.

\documentclass{article}
\usepackage{coloremoji}
\begin{document}
Hello, 🌎.
\end{document}

Or, use a public font, such as Google Noto to display native color emoji via the emoji package which uses Google’s Noto font. (requires LuaLaTeX). Overleaf’s explanation is good.

Emergency short minus

One should never hack the minus sign. However, sometimes one must because one is trying to fit equations of time series analysis into a multi column layout. Here is how I squeezed down \(t-1\) to \(t{\operatorname{-}}1\).

\newcommand{\tm}{t{\operatorname{-}}1} % "t-1" squeezed down

Stochastic independence symbol

A case study in doing typography right. The probabilistic independence symbol ⫫, unicode U+2AEB, UTF-8: E2 AB AB, (“double up tack”) does not ship in normal LaTeX maths systems for some reason. So how do you fake it? In one of many slightly unsatisfactory ways!

Jason Blevins suggests the following hacks:

\newcommand{\indep}{\perp \! \! \! \perp}

It has some shortcomings, such as not setting the symbol up as a proper operator, which probably means something bad in the complicated world of LaTeX spacing. Perhaps this would be better:

\newcommand{\indep}{\mathop{\perp \! \! \! \perp}}

Alternatively, the following does more specific space management.

\newcommand\indep{\protect\mathpalette{\protect\independenT}{\perp}}
\def\independenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2mu{#1#2}}}

Fibo Kowalsky adds the alternative:

\newcommand{\indep}{\raisebox{0.05em}{\rotatebox[origin=c]{90}{$\models$}}}

Ashwin Khadke notes that for classic LaTeX one can import the symbol in one of the massive math symbol fonts, e.g. mdsymbol:

\usepackage{mdsymbol}
\newcommand{\indep}{\upvDash}

All of these would probably benefit from declaring the created symbol to be a mathematical operator via \mathrel.

Note that mdsymbol is incompatible with amssymb and amsfonts although notionally it renders them unneeded. Also it is a sans serif math font, so may not fit with your aesthetic. And it redefines various useful characters and is generally a mess.

The generic glyph import also presumably works.

If I am using unicode-math, it is very simple. We can type it as

\usepackage{unicode-math}
\newcommand{\indep}{⫫}
\newcommand{\indep}{\symbol{"2AEB}}

Any of the above should result in the independence symbol being available for use as

$X \indep Y $

AFAIK only the Jason Blevins double \perp trick works for js mathematics, although in that case I believe you can just type ⫫ since js mathematics is happy with unicode.

Conditional |

The stochastic conditional symbol is also fiddly to type. Jason Blevins observes that spacing is differently allocated in normal and big sizes.

Normal size:

\Pr( A \mid B )

will get us

\[\Pr(A \mid B)\]

Big size needs a \; spacer set around a \middle\vert, e.g.:

\Pr\left( A \;\middle\vert\; \sum_{i=1}^N B_i \right)

for

\[\Pr\left( A \;\middle\vert\; \sum_{i=1}^N B_i \right)\]

Every moment spent thinking about this nonsense is a moment spent not saving the world or eating profiteroles or having sex or such.

Blackboard bold for non-letters

a.k.a. doublestroke. Notoriously annoying for numerals. Historically, for legacy fonts one used

\documentclass{article}
\usepackage{bbm}
\begin{document}
\[
  \mathbbm{1}
\]
\end{document}

This looks bad on modern PDFs, often coming out pixelly, and does not work in web browser mathes. Here are some alternatives.

Davislor’s recent advice suggests that the problem does not arise in unicode mathematics, but that a modern solution for legacy PdfTeX is

\documentclass{article}
\usepackage{amsmath}
\usepackage[bb=dsserif]{mathalpha}
\begin{document}
\[ \mathbb{1} \Bbbbone
\]
\end{document}

This one did not work for me. A pragmatic alternative that did:

\documentclass{article}
\DeclareSymbolFont{bbold}{U}{bbold}{m}{n}
\DeclareSymbolFontAlphabet{\mathbbold}{bbold}
\begin{document}
\[ \mathbbold{1} 
\]
\end{document}

In MathJax 2 the syntax is \mathbb{1} but you need to cross your fingers and hope because it depends upon something complicated about users’ browsers. MathJax 3 apparently works but all the software I use assumes MathJax 2. Some people endorse \unicode{x1D7D9} to write 𝟙 but reportedly it is unreliable and also it looks awful. Maybe in a macro?

Intercal

What is the \intercal symbol? No one knows, but possibly it is a reference to the Roman god Terminus which got into character sets in 1986 because of a single book in 1975 and has remained by inertia.

Tilde and backslash

How can I write these special TeX characters? Two answers

Classic:

\textasciitilde{}
\textbackslash{}

XeTeX/LuaTeX:

\char`~

Bold in mathematics

tl;dr: In mainline LaTeX, \usepackage{bm} then \bm everywhere In Mathjax, \boldsymbol everywhere.

I want to bold certain symbols in equations. Somtimes these symbols are greek letters, and sometimes roman letters. Possibly other things.

Back to the more immediate problem. Roman letters are bolded by \mathbf{x} and greek letters by \boldsymbol{\xi}.

If I write a macro which attempts to bold whatever, this leads to sadness. I need to know ahead of time what it is that I need to bold. How can I bold any old thing? The canonical answer from the AMS guide seems to be \boldsymbol and \bm with the bm package. This is fine, except that the bm package does not exist for Mathjax.Which is not fatal as such. \boldsymbol in Mathjax is more powerful than in vanilla LaTeX and will in fact bold anything, unlike in vanilla LaTeX. So there is a solution for each, just not seamless translation between them. I could try to work around this by writing macros to redefine \boldsymbol but this feels like it is asking for trouble, and macro support in Mathjax is not universal (e.g. it does not work if you are outputting to a powerpoint presentation.


No comments yet. Why not leave one?

GitHub-flavored Markdown & a sane subset of HTML is supported.