# Suppress arguments in output for pretty print

I would like to define a rule that suppress any arguments of a function for visibility. I tried:

rule = f_[x__] -> f


While this works well with individual terms (including derivatives of expressions), products of functions don't work, such as

f[x] R[r] /. rule


which outputs "Times" for some reason?

• It's because Head[f[x] R[r]] is Times. Nov 8 '19 at 11:47
• What should be displayed for f[ g[x] ]?
– Kuba
Nov 8 '19 at 11:57
• Good question. While this may be seen as unfortunate, the answer to that question would be just "f", since g(x) is an argument. Nov 10 '19 at 21:12
• I think I have a good answer to this question, so it would be nice to reopen. Nov 29 '19 at 5:09

## 2 Answers

It's because Head[f[x] R[r]] is Times. You should rewrite your rule as

rule = f_[x__] /; ! MatchQ[f, Times] :> f


Now

f[x] R[r] /. rule

f R


I would like to define a rule that suppress any arguments of a function for visibility.

I think my shortInputForm function can be of interest for you. It doesn't completely suppress arguments but rather shortens long lists of numbers for readability.

I think you can create a wrapper that modifies the box generation code so that it never generates brackets:

MakeBoxes[SuppressBracketArguments[expr_], StandardForm] ^:= ReplaceAll[
MakeBoxes[expr,StandardForm],
RowBox[{h_, "[",___,"]"}]->h
]


A couple examples:

f[g[x]] //SuppressBracketArguments
f[x] g[y] //SuppressBracketArguments


f

f g