I have a macro that typesets its arguments inside a set of parentheses \left(...\right). For simplicity, let's say it's

\newcommand{\func}[1]{ \ensuremath{ f \left( #1 \right) } }

Sometimes, the automatically-determined parentheses are too small for my taste. For example,func{\sin(x)} produces

enter image description here

If I weren't using the macro, I know I could just do (e.g.)

f \bigl( \sin(x) \bigr)

and obtain

enter image description here

so that the nested parentheses are visually-distinct.

How can I implement this ability to manually adjust parenthesis sizing within a macro? Of course, I could just define \funcbig, \funcBig etc., but is there a way to define a single macro with this behaviour?

  • 5
    You might want to look at \DeclarePairedDelimiter from mathtools. It seems to be becoming the de facto standard for such constructions (even if it is lacking some flexibility, in my opinion). Also, don’t wrap it all in \ensuremath. That will mess up stuff (or that is my impression at least).
    – Gaussler
    Aug 21, 2023 at 16:57
  • @Gaussler \DeclarePairedDelimiterX and \DeclarePairedDelimiterXPP provide more flexibility, though I assume that's not the inflexibility you're referring to
    – mbert
    Aug 21, 2023 at 17:39
  • 1
    @mbert I know about those. I consider them sub-species of the same command. And no, they still don’t provide enough flexibility with regard to e.g. adding decorations to the function symbol. For that, you still need to define separate commands. That’s why I made semantex (which, as far as I know, has exactly one active user, but he made it mainly for himself and hence doesn’t really care much 😉).
    – Gaussler
    Aug 21, 2023 at 17:51

1 Answer 1


Here's a definition of \func that employs the \DeclarePairedDelimiterXPP macro of the mathtools package. The \func macro works as follows:

  • \func{x} surrounds x with standard-size parentheses, i.e., is equivalent to f(x)

  • \func*{z} surrounds z with auto-sized parentheses

  • \func[\big]{u} surrounds u with \big-sized parentheses. In addition to \big, you can also state \Big, \bigg, and \Bigg as the optional argument of \func.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{mathtools} % for '\DeclarePairedDelimiterXPP' macro
\DeclarePairedDelimiterXPP{\func}[1]{f}{(}{)}{}{#1} % see p. 28 of user guide

\func{x} \quad 
\func*{\dfrac{\frac{a}{c}}{\frac{b}{d}}} \quad

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .