8

The line

i(x,y,z,t) = \delta(x-\ell_x(z)) \delta(y-\ell_y(z)) \hat{\imath}(\xi(z),t)

enter image description here

produces (for my eyes, at least) too little space between the successive function calls. It is difficult to visually distinguish the three calls. I guess the underlying reason is that the expressions that serve as function arguments are relatively long. For comparison,

i(x,y,z,t) = \delta(x) \delta(y) \hat{\imath}(\xi(z),t)

enter image description here

already looks a lot better in my opinion.

I know that I could

  1. Manually adjust spacing using \, etc., including the option to define a macro that does this automatically.
  2. Insert \cdot as a means of adding seperating space.

However, my question is: Is there a canonical way (e.g. a package) of dealing with this problem? I imagine I'm not the first one to encounter this problem... still, I wasn't able to find useful, general solutions to the problem.

A possible solution might be something along the lines of

i(x,y,t) = \delta \funcargs{x-\ell_x(z)} \delta \funcargs{y-\ell_y(z)} \hat{\imath} \funcargs{\xi(z)}{t}

Note that I find the use of \cdot to be unsatisfying since it introduces inconsistency in the document (sometimes having the dot and sometimes not, with the meaning being the same).

Eike P.
  • 699
  • 5
  • 14
  • 3
    Use \, or \; to add more space. – skpblack Nov 03 '14 at 14:39
  • As I said, I know that I can manually adjust spacing. This is not the solution I was asking for. I'll try to further clarify the question. – Eike P. Nov 03 '14 at 14:47
  • How do you feel about wrapping them inside \mathinner{...}s? – morbusg Nov 03 '14 at 14:49
  • Because the added space is dependent on what follows (another function[yes] vs. a comma or an additional close paren [no]), making it active would seem to be the only way. And making it active would introduce all sorts of other problems, I would guess. Thus, I agree with @skpblack that adding it manually is the best approach. – Steven B. Segletes Nov 03 '14 at 14:49
  • @Steven: With \mathinner, no space would be inserted between it and \mathclose, but \thinmuskip would be inserted between it and \mathpunct. – morbusg Nov 03 '14 at 14:56
  • @morbusg I see. Very nice. (but \, still seems simpler) – Steven B. Segletes Nov 03 '14 at 14:57
  • @morbusg I don't know about \mathinner. Thanks for the hint, going to research that right now. – Eike P. Nov 03 '14 at 14:58
  • @morbusg \mathinner does exactly what I want! If you add a short answer, I'll accept it. – Eike P. Nov 03 '14 at 15:24
  • No package can distinguish ) as function argument delimiter if you don't mark it in some way. My preferred way for avoiding ambiguities (if any) would be \cdot. – egreg Nov 03 '14 at 16:11

2 Answers2

11

First, let me give a paraphrasing from The TeXbook showing the amounts of spaces between different types of math atoms:

enter image description here

where

  • Ord includes things like a, \theta, and things inside \mathord or just plain {}'s;
  • Op includes things like \sin, \gcd, and things inside \mathop;
  • Bin includes things like \pm, \otimes, and things inside \mathbin;
  • Rel includes things like \leq, \mid, and things inside \mathrel;
  • Open includes things like \langle, (, and things inside \mathopen;
  • Close includes things like \rangle, ), and things inside \mathclose;
  • Punct includes things like ,, ., and things inside \mathpunct;
  • Inner includes things like \cdots and things inside \mathinner.

Here is an example document illustrating a couple of different ways:

\let\funarg\mathinner
\def\funop#1{\mathop{{}#1}}
$$ i(x,y,z,t) = \delta(x-\ell_x(z)) \delta(y-\ell_y(z)) \hat\imath(\xi(z),t), $$
$$ i\funarg{x,y,z,t} = \delta\funarg{(x-\ell_x(z))} \delta\funarg{(y-\ell_y(z))} \hat\imath\funarg{(\xi(z),t)}, $$
$$ \funarg{i(x,y,z,t)} = \funarg{\delta(x-\ell_x(z))} \funarg{\delta(y-\ell_y(z))} \funarg{\hat\imath(\xi(z),t)}, $$
$$ \funop i(x,y,z,t) = \funop\delta(x-\ell_x(z)) \funop\delta(y-\ell_y(z)) \funop{\hat\imath}(\xi(z),t), $$
\bye

enter image description here

So as you can see, you probably want the last option of using a \mathop atom for the function "name".

With LaTeX, this could be defined as follows (the second row below shows the output of your original code):

\documentclass{article}
\newcommand\funop[1]{\mathop{{}#1}}
\begin{document}
$i(x,y,z,t) = \funop\delta(x-\ell_x(z)) \funop\delta(y-\ell_y(z)) \funop{\hat\imath}(\xi(z),t)$

vs.

$i(x,y,z,t) = \delta(x-\ell_x(z)) \delta(y-\ell_y(z)) \hat{\imath}(\xi(z),t)$
\end{document}

(The reason I didn't include the parenthesis in the command is that I felt it would be too much effort to measure the arguments to decide on the size of the fences. I think it's simpler to just manually define the height with \bigl( etc., and also it's nicer to see the parens in the manuscript instead of {}'s)

enter image description here

morbusg
  • 25,490
  • 4
  • 81
  • 162
  • Thanks, this is really helpful! What I do right now is \newcommand{\func}[2]{\operatorname{#1} \left( #2 \right)}. I first tried \mathop as it seemed more appropriate than \mathinner but it resulted in weird vertival spacing, so I settled to \operatorname. I have \left and \right fixed as proposed in http://tex.stackexchange.com/a/2610/64293. The result looks really good in my opinion. – Eike P. Nov 03 '14 at 17:12
  • @jhin: Yes, the first empty group in my plain-tex definition takes care of the weird vertical spacing. I could have sworn there is either a LaTeX or AMSMath command to achieve the same thing, I'm just having trouble finding it. – morbusg Nov 03 '14 at 17:17
  • @jhin You can use \mleft and \mright from mleftright package. In any case, I wouldn't use them. I would prefer a wrapper around \DeclarePairedDelimiter\parenthesis{\lparen}{\rparen} and then passing the optional comand like \func[\big]{..}{..} to \parenthesis[\big]{..}. – Manuel Nov 03 '14 at 17:18
  • @Mico: Thanks! Though, I was thinking of a \mathop to be the "suggested" math atom because the \mathinner adds a \thinmuskip in case of a following \mathpunct atom. Do you recall if there is a LaTeX or AMSMath command which basically does \mathop{{}#1}? – morbusg Nov 03 '14 at 17:28
  • @Manuel - and could you elaborate a bit on why you would prefer such a wrapper over the \mleftrightpackage...? – Eike P. Nov 03 '14 at 17:42
  • @jhin \mleft and \mright are already “fixed” as in the answer you linked. In any case, better than using those automatic \left/\right which doesn't always choose the best option, I would prefer a wrapper around that delimiters which in general are recommended instead of \left/\right. – Manuel Nov 03 '14 at 17:56
  • @Mico - I'm confused: Why adding the extra Latex commands? I'm completely new to this distinction (Latex vs. plain-tex), just did a bit of read-up, but to me it seems that \mathop{{}#1} works in standard Latex aswell? (As should all plain-tex commands, if I get it right...?) Actually it is what I'm using right now (due to vertical alignment issues with \operatorname). – Eike P. Nov 04 '14 at 09:47
  • @jhin - For the example at hand, both approaches work. The "LaTeX approach" is to try to keep the content and the way it's displayed separate. The big advantage of setting up a macro such as \funop (and then using it consistently, of course) is that it allows for a quick and easy global style should you, say, at some point in the future want to use square brackets instead of round parentheses, or size the parentheses differently, of employ a different amount of spacing. Using \mathop hard-codes some of these choices, making it more difficult to modify the appearance of these terms. – Mico Nov 04 '14 at 13:21
  • @Mico - We completely agree on the benefit of macros! My question was why you proposed the use of \newcommand\funop[2]{\mathinner{#1(#2)}} as a "with Latex" solution instead of \newcommand\funop[2]{\mathop{{}#1}(#2)} as originally proposed by @morbusg ? – Eike P. Nov 04 '14 at 16:58
  • @jhin: I think I'm to blame here as I'm the one who brought up the \mathinner. Anyhow, let me change that into the answer. – morbusg Nov 04 '14 at 17:02
4

Inserting a thinspace (\,) between the multiplicative factors should work. Inserting \cdot in these locations should work too. You could also combine the thinspaces with making the outer parentheses a tad bigger than the inner ones (by using \bigl( and \bigr)). The three possibilities are illustrated below:

enter image description here

\documentclass{article}
\begin{document}
$i(x,y,z,t) = \delta(x-\ell_x(z)) \, \delta(y-\ell_y(z)) \, \hat{\imath}(\xi(z),t)$

$i(x,y,z,t) = \delta(x-\ell_x(z)) \cdot \delta(y-\ell_y(z)) \cdot \hat{\imath}(\xi(z),t)$

$i(x,y,z,t) = \delta\bigl(x-\ell_x(z)\bigr) , \delta\bigl(y-\ell_y(z)\bigr) , \hat{\imath}\bigl(\xi(z),t)\bigr)$ \end{document}

One can automate the third method by creating a macro such as

\def\myfunc#1{\bigl(#1\bigr)\,}

and then typing

$i(x,y,z,t) = \delta\myfunc{x-\ell_x(z)} \delta\myfunc{y-\ell_y(z)} 
    \hat{\imath}\myfunc{\xi(z),t)}$
Mico
  • 506,678
  • Thanks for the answer. I prefer the solution given by morbusg, though. Note that \bigl etc. introduce additional (undesired) spacing between the function name and the parentheses, see e.g. http://tex.stackexchange.com/questions/40829/equation-using-left-brackets-inserts-unwanted-space – Eike P. Nov 03 '14 at 15:23
  • @jhin - You may have misinterpreted that posting: The extra, unwanted space is inserted if one uses \left( and \right). In contrast, no extra space is inserted by \bigl( and \bigr). You can verify this assertion by modifying the third row of the code above to omit the two \, directives : You'll find that there's no absolutely no extra space. – Mico Nov 03 '14 at 15:56
  • I wasn't sure whether the two produce the same spacing, so I looked at your attached picture and concluded that yes they do, since in fact there is a larger space between the delta and the parenthesis in the third row than in the two previous rows... might just be the effect of the scaling, though. Thanks for correcting me! – Eike P. Nov 03 '14 at 16:23
  • @jhin - The additional whitespace in the third row comes from the \, macros, not from \bigl( and \bigr). It's exactly the same amount of whitespace as in the first row (which also uses \, macros). – Mico Nov 03 '14 at 17:09
  • Sorry, perhaps should have clarified: I'm really referring to the whitespace between the \delta and its successive ( or \bigl, respectively. And that is indeed a tiny little bit larger in the third row than in the two previous rows. – Eike P. Nov 03 '14 at 17:17
  • @jhin That's a mix of the glyph design and the viewer Mico was using. The glyph itself has more space, but the viewer clearly shows it as extreme. – Manuel Nov 03 '14 at 17:20
  • @jhin - Thanks. For me, the main advantage of using different sizes for the inner and outer parentheses is a modest improvement in the legibility/parsability of the entire formula. Obviously, if you think that your formulas are readable enough when all parentheses have exactly the same size, there would be no point in making the sizes vary. – Mico Nov 03 '14 at 17:55