Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Last active November 27, 2016 18:40
Show Gist options
  • Save lucaswerkmeister/6e482307e943e5d37c37144628987d3e to your computer and use it in GitHub Desktop.
Save lucaswerkmeister/6e482307e943e5d37c37144628987d3e to your computer and use it in GitHub Desktop.
Make ? indicate a single-letter variable in math mode
\documentclass{article}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{3BB}{\lambda} % λ
\newcommand{\var}[1]{\mathtt{#1}}
\let\qm=?
\catcode`?=13
\def?{%
\ifmmode%
\expandafter\var%
\else%
\qm%
\fi%
}
\begin{document}
In text mode, the question mark still indicates a question:
\begin{quotation}
How does this work?
\end{quotation}
In math mode, however, it indicates a single-letter variable:
\[(a,b) \quad\hat=\quad λ?f.~?f~a~b\]
\end{document}
@lucaswerkmeister
Copy link
Author

screenshot from 2016-11-27 19-41-48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment