I would like to get a macro \of to define a function with an optional macro \at to define its restriction.
The reason is, that I don't like the spacing for functions (as there is no spacing) and I would like to automate that. The idea is, to set functions like f \of x or f\of x which would be quick and handy. But I am not sure, if that is doable for syntax reasons. I think, something like \func{f}{x} would be much easier to provide, but that would be too much typing and quite a lot of change for already existing formulae.
However, the reasons for this macro are the following properties which I would like to achieve. In future I want to expand this to all kind of derivatives or alike (total, partial, normal, increment, infinite element...).
Here is the list:
- Always set argument (value behind
\ofin () - Recognize x, (x), and {x} as argument
- always set half space in front of the function when it is set behind a letter, number or bracket
- set half space behind the function, if followed by a (
- allow powers to the function and to the argument and set it properly
- allow nested functions
- allow
\at-notation with three optional formats (this will get interesting later on for the derivatives...)
And here are some examples:
\documentclass{article}
\usepackage{mathtools}
\usepackage[partial=upright]{unicode-math}
\begin{document}
\begin{verbatim}f \of x=x^2\end{verbatim}
$f(x)=x^2$
\begin{verbatim}f \of (x+y)=x+y\end{verbatim}
$f(x+y)=x+y$
\begin{verbatim}f \of (x+y)x+y\end{verbatim}
$f(x+y)x+y$
\begin{verbatim}f \of (x+y)(x+y)(x+y)\end{verbatim}
$f(x+y)\,(x+y)(x+y)$
\begin{verbatim}xf \of xx\end{verbatim}
$x\,f(x)x$
\begin{verbatim}zf \of xg \of yz\end{verbatim}
$z\,f(x)\,g(y)z$
\begin{verbatim}f^2 \of x\end{verbatim}
$f^2(x) \vee f(x)^2 \vee (f(x))^2 \quad \text{don't know which one is correct}$
\begin{verbatim}f \of x^2\end{verbatim}
$f(x^2)$
\begin{verbatim}f \of g \of x\end{verbatim}
$f(g(x))$
\begin{verbatim}\frac{a}{b}f\of x\end{verbatim}
$\dfrac{a}{b}f(x)$
\begin{verbatim}(a+b)f\of x\end{verbatim}
$(a+b)\,f(x)$
\begin{verbatim}\setFunctionAtBar \end{verbatim}
\begin{verbatim}f \of x \at a\end{verbatim}
$f(x)|_{x=a}$
\begin{verbatim}\setFunctionAtBracket\end{verbatim}
\begin{verbatim}f \of x \at {a+b}\end{verbatim}
$(f(x))_{x=(a+b)}$
\begin{verbatim}\setFunctionAtInline\end{verbatim}
\begin{verbatim}f \of x \at (a+b)\end{verbatim}
$f(a+b)$
\end{document}

\frac{a}{b}nota \over b,\hspace{2in}not\hskip 2inetc :( – David Carlisle Sep 20 '13 at 11:37$(a+b)\,f(x)$or(f(x))_{}, ie. inserting things way before\ofis almost impossible without making things active or pre-processing the whole content. The\ofdoesn't know what came before it. (You can however put\mathinner{(a+b)}which, I believe, includes spacing around it.) Otherwise this is probably doable with a fewifnextchars, but do you really want that (see David's comment)?xparsecan probably help with a\funcmacro. – Qrrbrbirlbel Sep 20 '13 at 12:06