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 \of in ()
  • 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:


\begin{verbatim}f \of x=x^2\end{verbatim}
\begin{verbatim}f \of (x+y)=x+y\end{verbatim}
\begin{verbatim}f \of (x+y)x+y\end{verbatim}
\begin{verbatim}f \of (x+y)(x+y)(x+y)\end{verbatim}
\begin{verbatim}xf \of xx\end{verbatim}
\begin{verbatim}zf \of xg \of yz\end{verbatim}
\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}
\begin{verbatim}f \of g \of x\end{verbatim}
\begin{verbatim}\frac{a}{b}f\of x\end{verbatim}
\begin{verbatim}(a+b)f\of x\end{verbatim}
\begin{verbatim}\setFunctionAtBar \end{verbatim}
\begin{verbatim}f \of x \at a\end{verbatim}
\begin{verbatim}f \of x \at {a+b}\end{verbatim}
\begin{verbatim}f \of x \at (a+b)\end{verbatim}
  • 3
    latex goes to a lot of effort to have a consistent syntax \frac{a}{b} not a \over b, \hspace{2in} not \hskip 2in etc :( Sep 20, 2013 at 11:37
  • hmmm, I will think of an other notation, which would be easy. But is there something around, doing the other stuff? I got the feeling, there has to be something, but I can't find it.
    – LaRiFaRi
    Sep 20, 2013 at 11:56
  • 3
    Something like $(a+b)\,f(x)$ or (f(x))_{}, ie. inserting things way before \of is almost impossible without making things active or pre-processing the whole content. The \of doesn'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 few ifnextchars, but do you really want that (see David's comment)? xparse can probably help with a \func macro. Sep 20, 2013 at 12:06
  • I already gathered that the syntax is the major problem. But your point about pre-processing is very interesting. I will have a look on xparse when CTAN is on again.
    – LaRiFaRi
    Sep 20, 2013 at 12:10

1 Answer 1


Aside from syntax it seems main issue is spacing before a function term. TeX will add space there automatically if it knows it is a function. \log \sin etc are \mathop atoms and get space, but f is a mathord so does not. If you declare a one-letter math operator though, it gets the space that I think you want:

enter image description here





Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.