I am only recently learning about the importance of being consistent with markup when typesetting a document in LaTeX (Separate content from formatting - i.e., "just type"). For instance,

  • \emph is a semantic markup, and not exactly an alternative to \textit: \emph or \textit
  • Using \vec for vectors is good practice, not because vectors should be typeset with arrows above them, but because we have the freedom to redefine \vec later on for it to appear as we wish: How to change all \vec{} to \bf{}
  • There are various kinds of \dots commands for use in different semantic contexts: Difference of the \dots*

Along the same lines, I am now wondering whether it is good to define a custom command, say \func, to be used for markup of functions. For example, would it be better to consistently write something like \(\func{f}(x), \func{g}(x_1, \dotsc, x_n)\) instead of just \(f(x), g(x_1, \dotsc, x_n)\)?

I searched on this site before posting but could not find any discussion specifically about this aspect. This interesting question is related, but it asks how this can be done rather than if this should be done: How can I influence the spacing of mathematical functions by an own macro?

  • 8
    Short answer: yes, but only if that make your life easier. For instance, I would use \specie{hOMO hOrribilis} if I want this string with emphasis, indexed, abbreviated and correctly capitalized as any scientific name (i.e., " H. horribilis ") but I would not use \flower{marguerite} if I want just type "marguerite".
    – Fran
    Mar 8, 2020 at 7:51
  • 8
    IMO, customization command is a way to reserve the room for future format changes. If you are pretty sure that there is no need for future changes, you don't need to bother yourself with overlength or complicated customized commands.
    – wklchris
    Mar 8, 2020 at 7:53

1 Answer 1


I have spent years brainstorming about how to make the TeX math syntax more semantic, particularly when it comes to variables and functional expressions. Eventually, my efforts became the package SemanTeX. It has an object-oriented approach to mathematics where each variable belongs to a class, and classes are set up using keyval syntax. You can have a look at the syntax below:



\NewVariableClass\MyVar % creates a new class of variables, called "\MyVar"

% Now we create a couple of variables of the class \MyVar:

% Now we set up the class \MyVar:
    output=\MyVar,  % This means that the output of an object
                    % of class \MyVar is also of class \MyVar
    % We add a few keys for use with the class \MyVar:
    define keys={ % we define a few keys
        {conj}{command=\overline}, % Applies \overline to the symbol
        {inverse image}{upper={-1},no par},
    define keys[1]={ % we define keys taking 1 value
        {stalk}{sep lower={#1}},
        % "sep lower" means "separator + lower", i.e. lower index
        % separated from any previous lower index by a separator,
        % which by default is a comma
        {res}{ right return, symbol put right={|}, lower={#1} },


$ \vf[conj,der=\vn] $

$ \vg[inv,res=\vU]{\vx} $

$ \vh[inverse image]{\sheafF}[spar,stalk=\vp]
    = \sheafF[stalk=\vh{\vp}] $


enter image description here

You must log in to answer this question.