% \DocumentMetadata{tagging=on}
\documentclass[11pt]{article}

\usepackage{geometry}

\usepackage{mlmodern}

\usepackage{enumitem}
\setlist[itemize]{align=parleft,left=0pt..30pt}

\parindent=0pt
\parskip=\medskipamount

\usepackage[hidelinks]{hyperref}

\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\usepackage{freemath}
\freemathon

% \usepackage{mleftright}
% \mleftright

\protected\def\link{\futurelet\tempa\linkA}
\def\linkA{\ifx[\tempa \expandafter\linkB \else \expandafter\linkC \fi}
\long\def\linkB[#1]#2{\href{#2}{\ttul{#1}}}
\long\def\linkC#1{\href{#1}{\ttul{#1}}}
\protected\long\def\email#1{\href{mailto:#1}{\ttul{#1}}}

\protected\long\def\ttul#1{%
	\leavevmode
	\setbox0=\hbox{\ttfamily #1}%
	\lower2.25pt\rlap{\leaders\hrule height.625px\hskip\wd0}%
	\pdfliteral{q 1 G 2 Tr 1.7 w 1 j 1 J}%
	\rlap{\copy0}%
	\pdfliteral{Q}%
	\box0
}

\title{The \texttt{freemath} Package, version 1.1}
\author{plante}

\begin{document}

\maketitle

\noindent

\subsection*{Usage}

The \texttt{freemath} package allows for the omission of backslashes from most math mode commands. Specifically, any maximal consecutive string of at least two (Latin) letters appearing in math mode will automatically be replaced with the control sequence having the same name, if it is defined.

The package is loaded by \verb|\usepackage{freemath}| and provides the \verb|\freemathon| and \verb|\freemathoff| commands which respectively activate and deactivate this behaviour. It is \textbf{disabled} by default upon loading.

Regular commands initiated by a backslash may of course still be used when freemath is active, and can furthermore be freely mixed with backslash-free commands.

To prevent undesirable command formation simply insert spaces in-between letters to break the word apart (eg.\ to write the product of three variables $e$, $x$, and $p$ you can write \verb|e x p|, \verb|ex p|, or \verb|e xp|).

\medskip

\textit{Example with freemath:} \vadjust{\vskip-\medskipamount}
\[ \hbox{\verb|lim_{n to infty} int_Omega n log left( 1 + frac{f}{n} right) d mu|}. \]
\textit{Example without freemath:} \vadjust{\vskip-\medskipamount}
\[ \hbox{\verb|\lim_{n\to\infty} \int_\Omega n \log\left( 1 + \frac{f}{n} \right) d\mu|}. \]

\vskip-\medskipamount
\[ lim_{n to infty} int_Omega n log left( 1 + frac{f}{n} right) d mu. \]

\subsection*{Known Limitations}

\begin{itemize}

\item Braces are required whenever such a string of letters appears as an argument to another macro. For instance, one must write \verb|frac{omega}{phi}| instead of \verb|frac omega phi|, even though \verb|\frac\omega\phi| is acceptable in ordinary \LaTeX.

Exceptions to the rule above are superscripts, subscripts, and \verb|\left| \verb|\right|, where for instance \verb|left lVert f_mu right rVert| renders as expected ($left lVert f_mu right rVert$).

\item When used in conjunction with the \texttt{unicode-math} package, some math mode commands like \verb|\sqrt| and \verb|\vec| require mandatory braces for single-letter arguments.

% \item
% Braces are required around the argument to \verb|\sqrt| even when it consists of a single letter.
% Backslash commands must be used for \verb|\left| and \verb|\right| delimiters that are not single characters (eg.\ \verb|left \lVert|).

\end{itemize}

Changes to \LaTeX\ internals are summarised below:

\begin{itemize}

\item All letters are assigned a mathcode of \verb|"8000| (\verb|"1000000| in Lua\LaTeX).

\item The characters \verb|^| and \verb|_| have been made active (category code 13).

\item The primitives \verb|\left| and \verb|\right| have been redefined.

\item The primitive \verb|\radical| has been redefined to have a macro-style argument in the second parameter.

\item Commands which typeset their own name may result in infinite loops.
One class of such commands is the math operators (eg.\ \verb|\lim|, \verb|\exp|) and the package includes a fix in this case by modifying \verb|\operator@font|.
The workaround in general is to patch these commands to insert \verb|\freemathoff| locally.

\end{itemize}

\subsection*{License}

This package is copyright \copyright\ 2025 plante, and
released under the \LaTeX\ Project Public License (\textsc{lppl}) 1.3c.

\subsection*{Repository}

The upstream repository of this package may be found at
	\[ \link{https://github.com/plante3/freemath/tree/main}. \]

\end{document}

\newpage

\begingroup
\everymath={\displaystyle} \openup3\jot \obeylines
\def\abs#1{\lvert#1\rvert}

$phi_g(x)$  $f_theta^xi(omega)$ $a^2+b^2=c^2$ $x^n+y^n=z^n$ $A_abc$ $A_alpha$ $x_ix_j$
$forall epsilon > 0 \, forall x in S \, exists delta > 0 \ abs{y-x} < delta implies abs{f(y)-f(x)} < epsilon$
$limsup_{n to infty} frac{abs{a_{n+1} - L}}{abs{a_n - L}^mu} < infty$
$prod_{n=2}^infty e left( 1 - frac{1}{n^2} right)^{n^2} = frac{pi}{e sqrt e}$
$sin 2x = 2 sin x cos x$ $displaystyle sum_{i=1}^infty sum_{j=1}^i a_{i j} < e$ $prod_i sin(2^i x)$
$frac{partial^2 ell(beta)}{partial beta partial beta^top} = -sum_{i=1}^N x_i x_i^top p(x_i; beta)(1 - p(x_i; beta))$
$left lVert vec u + vec v right rVert leq left lVert vec u right rVert + left lVert vec v right rVert $
$norm{ vec u + vec v } leq norm{vec u} + norm{vec v}$
$norm{ frac12 } norm*{ frac12 } norm[\Big]{ frac12 }$
$biggl{lVert} x biggr{rVert}$
$R_theta = begin{bmatrix} cos theta & -sin theta \\ sin theta & cos theta end{bmatrix}$

\endgroup

\end{document}

